interstiCy
A fast Rust implementation of spaCy tokenization with Python bindings.
Overview
interstiCy speeds up spaCy's tokenizer by implementing the tokenization
rules in Rust and exposing them to Python via PyO3/maturin. It produces
token boundaries that match spaCy for supported languages.
Benchmarks
Benchmarks are run with pytest-benchmark on the same CPU and text. Results
vary with hardware and text characteristics, but typical numbers are:
| Text type | spaCy | interstiCy | Speedup |
|---|---|---|---|
| Repetitive English paragraph (cached, ~200k chars) | ~218 ms | ~17 ms | ~13x |
| Real-world prose (Pride and Prejudice, 728k chars) | ~616 ms | ~272 ms | ~2.3x |
Run the standalone benchmark script yourself:
python benchmarks/benchmark.py
This downloads a public-domain text from Project Gutenberg and compares
intersticy.Tokenizer.tokenize() against spacy.blank("en").
Installation
pip install intersticy
Usage
import spacy
import intersticy
nlp = spacy.load("en_core_web_sm")
nlp.tokenizer = intersticy.create_tokenizer(nlp)
doc = nlp("Hello, world!")
print([t.text for t in doc])
# ['Hello', ',', 'world', '!']
You can also use the standalone tokenizer:
from intersticy import Tokenizer
tok = Tokenizer.load_from_spacy()
print(tok.tokenize("Hello, world!"))
# ['Hello', ',', 'world', '!']
Development
python -m venv .venv
source .venv/bin/activate
pip install -e ".[dev]"
pytest
License
MIT
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file intersticy-0.1.0.tar.gz.
File metadata
- Download URL: intersticy-0.1.0.tar.gz
- Upload date:
- Size: 31.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.11.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
61bbef0900b6a46bfdd3c3e5786043ffe09a29f6edc0242b6f8b565fe01d66f0
|
|
| MD5 |
5381a3cf1372d3ff5e0fd233766a4b21
|
|
| BLAKE2b-256 |
d4e754db92fe9355b17f9fea6d9c5789f199849981906237854f9c13f2d05d47
|
File details
Details for the file intersticy-0.1.0-cp39-abi3-manylinux_2_34_x86_64.whl.
File metadata
- Download URL: intersticy-0.1.0-cp39-abi3-manylinux_2_34_x86_64.whl
- Upload date:
- Size: 1.2 MB
- Tags: CPython 3.9+, manylinux: glibc 2.34+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.11.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b0f83dd4605045af8e0f6f70779a5e121553110add9a41e37678bb1f3ff5b577
|
|
| MD5 |
9cf564996ae5670526008e1e60b76365
|
|
| BLAKE2b-256 |
6e6f628ed3f22a1e808090c06ef1efafd2313130a22fd856bde1b19c09cd8602
|