# I Built a Python Compressor Using OpenAI's Tokenizer. Here's What Happened

DevFeed: [I Built a Python Compressor Using OpenAI's Tokenizer. Here's What Happened](<https://devfeed.tech/articles/i-built-a-python-compressor-using-openai-s-tokenizer-here-s-what-happened-92542.md>)

Original publisher: [Read original article](<https://hackernoon.com/i-built-a-python-compressor-using-openais-tokenizer-heres-what-happened?source=rss>)

Author: Lê Đức Minh

Published: 2026-10-21T07:28:58Z

Content type: article

Language: en

Sources: [HackerNoon](<https://devfeed.tech/sources/hackernoon.md>)

Topics: [Python](<https://devfeed.tech/topics/python.md>), [Tool](<https://devfeed.tech/topics/tool.md>), [concatenation](<https://devfeed.tech/topics/concatenation.md>), [OpenAI](<https://devfeed.tech/topics/openai.md>), [Large Language Model](<https://devfeed.tech/topics/llm.md>)

Tags: [1-3](<https://devfeed.tech/tags/1-3.md>), [adaptive](<https://devfeed.tech/tags/adaptive.md>), [algorithm](<https://devfeed.tech/tags/algorithm.md>), [allowed](<https://devfeed.tech/tags/allowed.md>), [amazon-documentdb](<https://devfeed.tech/tags/amazon-documentdb.md>), [api](<https://devfeed.tech/tags/api.md>), [batch](<https://devfeed.tech/tags/batch.md>), [beats](<https://devfeed.tech/tags/beats.md>), [benchmarking](<https://devfeed.tech/tags/benchmarking.md>), [bits](<https://devfeed.tech/tags/bits.md>), [blog](<https://devfeed.tech/tags/blog.md>), [blogging](<https://devfeed.tech/tags/blogging.md>), [bpe-tokenization](<https://devfeed.tech/tags/bpe-tokenization.md>), [brotli](<https://devfeed.tech/tags/brotli.md>), [career](<https://devfeed.tech/tags/career.md>), [content-creation](<https://devfeed.tech/tags/content-creation.md>), [entropy](<https://devfeed.tech/tags/entropy.md>), [field-notes](<https://devfeed.tech/tags/field-notes.md>), [large-language-models](<https://devfeed.tech/tags/large-language-models.md>), [llm](<https://devfeed.tech/tags/llm.md>), [llm-tokenization](<https://devfeed.tech/tags/llm-tokenization.md>), [machine-learning](<https://devfeed.tech/tags/machine-learning.md>), [notes](<https://devfeed.tech/tags/notes.md>), [openai](<https://devfeed.tech/tags/openai.md>), [python](<https://devfeed.tech/tags/python.md>), [teaching](<https://devfeed.tech/tags/teaching.md>)

## AI overview

TokPress is a pure-Python lossless compressor that tokenizes raw bytes with OpenAI's o200k_base, applies LZ77 to token IDs, then codes them with rANS. Its strongest reported result comes from batching: 150 schema-similar JSON records compressed as one adaptive stream to 0.0875x their original size, while compressing them separately produced a 1.19 ratio. A trained TokDict adds match history and prebuilt entropy tables, but depends on data resembling its training domain; on held-out logs, TokPress remained 1.3x larger than zstd using the same training data. The author reports wins over gzip on prose and some wins over zstd, while stressing that tokenization preserves information: gains come from modeling, entropy coding, and shared dictionaries. Compression is slower because the encoder evaluates multiple modes; decompression is reported at thousands of records per second.

## Source excerpt

Field notes from a weekend spent teaching an entropy coder to speak LLM.