
8/11/2026
What this post added
This post details the v2 release of fastokens, which adds native support for tiktoken models, replaces the pretokenization regex with a hand-written Unicode scanner, and rebuilds the BPE core for performance. Key improvements include direct loading of tiktoken.model files, a faster pretokenizer with byte checks and tables for ASCII and non-ASCII characters, and an optimized BPE encode loop leveraging cache hits. For serving, it introduces a prefix cache for shared prompts and `encode_batch_flat` for efficient batch output. All changes are validated bit-for-bit against reference tokenizers.