tiktoken-fast for Python
A drop-in for tiktoken that returns the same token ids, faster. It keeps tiktoken's Python layer, its encoding files and model names, and replaces only the core that turns text into tokens.
import tiktoken_fast as tiktoken
enc = tiktoken.get_encoding("o200k_base")
enc.encode("hello world")
enc.encode_batch(texts, num_threads=8)
Or, for code that already imports tiktoken:
import tiktoken_fast
tiktoken_fast.patch() # tiktoken.get_encoding and encoding_for_model now return fast encodings
Two additions that tiktoken does not have:
enc.count_tokens(text) # len(enc.encode(text)) without building the list
python -m tiktoken_fast.bench # compare with tiktoken on this machine, about 15 s
The bench uses text every Python installation has (the standard library's
source and docstrings) unless you pass --file. It checks that every call
returns tiktoken's tokens before it times anything.
Every encoding tiktoken ships (r50k_base, p50k_base, p50k_edit,
cl100k_base, o200k_base, o200k_harmony) runs on the new core. An
Encoding built with a split pattern the core does not know keeps tiktoken's
core. tiktoken_fast.Encoding is a subclass of tiktoken.Encoding, so type
checks and pickling work as before.
Speed
Against tiktoken 0.14 through the same Python calls, one core of a Xeon
Platinum 8481C, Python 3.11, 2026-10-26. Geometric means over Wikipedia in
eleven languages, 512-byte chat chunks, code and two books, under cl100k_base
and o200k_base; slowest workload in brackets. No document's tokens differed.
On AMD EPYC 9B14 and Google Axion encode_ordinary() is 3.78x and 3.50x
(all three machines).
| call | new text | fresh caches per document |
|---|---|---|
encode() |
3.21x [1.84x] | 2.64x |
encode_ordinary() |
3.28x [1.80x] | 2.72x |
Short texts gain more, because tiktoken spends most of a short call in Python:
encode() on 16-byte strings is 3.3x faster, and a batch of 16-byte strings
on four vCPUs 20x to 24x faster. Raw output is in
bench/results/2026-10-26-python.
Build
pip install maturin
cd python && maturin build --release && pip install target/wheels/*.whl
python -m pytest tests
Needs Python 3.10 or later and a Rust toolchain. The tests compare every public method with tiktoken.
Metadata
Release files for tiktoken-fast 0.1.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| tiktoken_fast-0.1.3.tar.gz | 3.4 MB | With provenance | Details for tiktoken_fast-0.1.3.tar.gz |
Built distributions (wheels)
| File | Actions Reset | |||
|---|---|---|---|---|
| tiktoken_fast-0.1.3-cp310-abi3-win_amd64.whl | CPython 3.10 | abi3 | Windows x86-64 | Details for tiktoken_fast-0.1.3-cp310-abi3-win_amd64.whl |
| tiktoken_fast-0.1.3-cp310-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl | CPython 3.10 | abi3 | Linux glibc 2.17+ x86-64 | Details for tiktoken_fast-0.1.3-cp310-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl |
| tiktoken_fast-0.1.3-cp310-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl | CPython 3.10 | abi3 | Linux glibc 2.17+ ARM64 | Details for tiktoken_fast-0.1.3-cp310-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl |
| tiktoken_fast-0.1.3-cp310-abi3-macosx_11_0_arm64.whl | CPython 3.10 | abi3 | macOS 11.0+ ARM64 | Details for tiktoken_fast-0.1.3-cp310-abi3-macosx_11_0_arm64.whl |
| tiktoken_fast-0.1.3-cp310-abi3-macosx_10_12_x86_64.whl | CPython 3.10 | abi3 | macOS 10.12+ x86-64 | Details for tiktoken_fast-0.1.3-cp310-abi3-macosx_10_12_x86_64.whl |
Total release size: 5.8 MB
Release files / tiktoken_fast-0.1.3.tar.gz
| Download URL | tiktoken_fast-0.1.3.tar.gz |
|---|---|
| Size | 3.4 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a47feba67a1f62a579dc7ba835e9fef48c9b099feccd628e1e4db55576f9a9a8
|
|
BLAKE2b-256 checksum How to use checksums |
214330e3f02b1dbd53d27f4c25b85810620af125b8733fda4dfe6fea445bf013
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 30, 2026.
Transparency logRelease files / tiktoken_fast-0.1.3-cp310-abi3-win_amd64.whl
| Download URL | tiktoken_fast-0.1.3-cp310-abi3-win_amd64.whl |
|---|---|
| Size | 407.3 kB |
| Tags | CPython 3.10 Windows x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
0482323074949ce99978ba8623d75a0efcdd0a01d22c2d79da0a581fd746e9a6
|
|
BLAKE2b-256 checksum How to use checksums |
db67cfcffabeb4dd41abbcca8e68a0f575ff9f3308dfcf75644ba25c0b9de3bc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 30, 2026.
Transparency logRelease files / tiktoken_fast-0.1.3-cp310-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
| Download URL | tiktoken_fast-0.1.3-cp310-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl |
|---|---|
| Size | 541.3 kB |
| Tags | CPython 3.10 Linux glibc 2.17+ x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
51c878d7216123c43f094114b613e085b192267ac1bc4a6bca0984f3f52d893b
|
|
BLAKE2b-256 checksum How to use checksums |
850056d9416318524e99f75ef78bb0efd605614e5c9fa7e8ba992dd52a7a2f62
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 30, 2026.
Transparency logRelease files / tiktoken_fast-0.1.3-cp310-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
| Download URL | tiktoken_fast-0.1.3-cp310-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl |
|---|---|
| Size | 540.8 kB |
| Tags | CPython 3.10 Linux glibc 2.17+ ARM64 abi3 |
|
SHA-256 checksum How to use checksums |
cdf6fecfd548d594751ca6b32f3fcdea0325a7530c2d72b498b86dcb17b0ed86
|
|
BLAKE2b-256 checksum How to use checksums |
7bd37aab61592a19cfea20bbedf7e4c86c41356f55900d13edbc32a6fa41d944
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 30, 2026.
Transparency logRelease files / tiktoken_fast-0.1.3-cp310-abi3-macosx_11_0_arm64.whl
| Download URL | tiktoken_fast-0.1.3-cp310-abi3-macosx_11_0_arm64.whl |
|---|---|
| Size | 478.1 kB |
| Tags | CPython 3.10 abi3 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
0423fe3621bb7c3a331864a33c750914f44c969e52df4a5061de9ab3305d0301
|
|
BLAKE2b-256 checksum How to use checksums |
817365e1eaa10b44a51f2d822662b2dcff9f9eb8ea0d587e69f2e246978b2cb4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 30, 2026.
Transparency logRelease files / tiktoken_fast-0.1.3-cp310-abi3-macosx_10_12_x86_64.whl
| Download URL | tiktoken_fast-0.1.3-cp310-abi3-macosx_10_12_x86_64.whl |
|---|---|
| Size | 504.4 kB |
| Tags | CPython 3.10 abi3 macOS 10.12+ x86-64 |
|
SHA-256 checksum How to use checksums |
dc659edff28aa9e4d92ae9ff356cdb90facf7343490e5f2e5b0bd643825c30d9
|
|
BLAKE2b-256 checksum How to use checksums |
5918b2dcd867c4199ec64e81e063576394c8b31faab2e49e5e5b89b4cb09879d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 30, 2026.
Transparency logSecurity for tiktoken-fast 0.1.3
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
All 6 files in this release have been uploaded with provenance metadata.
Attestation for tiktoken_fast-0.1.3.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 30, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.