Skip to main content

🚀 supertokens

A high-performance tokenizer for Python — powered by a C++ extension built with nanobind and Meson.

PyPI version Python PyPI downloads C++ License: MIT Build

Linux

macOS

Windows

✨ Features

  • ⚡ Fast — core tokenization in C++, zero-copy bindings via nanobind
  • 🔤 BPE tokenization — Byte-Pair Encoding implementation with full Unicode support via utfcpp
  • 🗺️ Robin-map backend — hash map operations use tsl::robin_map for cache-friendly performance
  • 🐍 Clean Python API — expressive, Pythonic interface over the C++ core
  • 🏗️ Meson build system — reproducible builds, easy subproject management

📦 Installation

From PyPI

pip install supertokens

From source

Prerequisites:

  • Python ≥ 3.10
  • C++17 compiler (g++, clang++, or MSVC 2019+)
  • Meson ≥ 1.1 and Ninja
git clone https://github.com/yourorg/supertokens.git
cd supertokens
pip install .

Or with editable/dev install:

pip install --no-build-isolation -e .

🔧 Building Manually (Meson)

# Configure
meson setup build --wipe

# Compile
meson compile -C build

# Run tests
meson test -C build

🚀 Quick Start

from supertokens import BPE

# Load a pre-trained tokenizer
tokenizer = BPE.from_file("tokenizer.sha")

# Encode text
ids = tokenizer.encode("Hello, world!")
print(ids)  # [15496, 11, 995, 0]

# Decode tokens
text = tokenizer.decode(ids)
print(text)  # "Hello, world!"

📖 API Reference

supertokens.model

Lower-level access to the underlying model data structures. See python/supertokens/model.py for details.


🗂️ Project Structure

supertokens/
├── python/supertokens/       # Python package
│   ├── __init__.py
│   ├── BPE.py                # High-level BPE tokenizer
│   └── model.py              # Model data types
│
├── src/                      # C++ extension source
│   ├── bindings.cxx          # nanobind Python bindings
│   ├── tokenizer/
│   │   ├── bpe.cxx / .hxx    # BPE algorithm
│   │   └── datatypes.hxx     # Shared types
│   ├── utils/                # String & BPE utilities
│   └── libs/
│       ├── expected.hxx      # std::expected polyfill
│       └── utfcpp/           # UTF-8 string handling
│
├── subprojects/              # Meson subprojects (vendored)
│   ├── nanobind-2.12.0/      # Python ↔ C++ bindings
│   └── robin-map-1.4.0/      # Fast hash map
│
├── meson.build               # Top-level build definition
└── pyproject.toml            # Python package metadata

🔩 Dependencies

Dependency Version Role
nanobind 2.12.0 C++ ↔ Python bindings
tsl::robin-map 1.4.0 High-performance hash map
utfcpp bundled UTF-8 string processing
expected.hxx bundled Error handling polyfill

All C++ dependencies are vendored under subprojects/ and managed by Meson — no manual installation required.


Code style

  • C++: follow the existing .cxx/.hxx style; C++17 standard
  • Python: Black + Ruff
black python/
ruff check python/

📋 Changelog

See CHANGELOG.md for release history.


🤝 Contributing

Contributions are welcome! Please:

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/my-feature)
  3. Commit your changes
  4. Open a Pull Request

For major changes, open an issue first to discuss the approach.


📄 License

This project is licensed under the MIT License. See LICENSE for details.

Third-party licenses:

Metadata

Release files for supertokens 0.1.5

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for supertokens 0.1.5
File Size Uploaded Provenance Actions
supertokens-0.1.5.tar.gz 2.0 MB With provenance Details for supertokens-0.1.5.tar.gz

Built distributions (wheels)

Table of built distributions (wheels) for supertokens 0.1.5
File Interpreter ABI Platform Actions
supertokens-0.1.5-cp313-cp313-win_amd64.whl CPython 3.13 CPython 3.13 Windows x86-64 Details for supertokens-0.1.5-cp313-cp313-win_amd64.whl
supertokens-0.1.5-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl CPython 3.13 CPython 3.13 Linux glibc 2.28+ x86-64, Linux glibc 2.27+ x86-64 Details for supertokens-0.1.5-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
supertokens-0.1.5-cp313-cp313-macosx_11_0_arm64.whl CPython 3.13 CPython 3.13 macOS 11.0+ ARM64 Details for supertokens-0.1.5-cp313-cp313-macosx_11_0_arm64.whl

Total release size: 2.3 MB

Release files / supertokens-0.1.5.tar.gz

Download URL supertokens-0.1.5.tar.gz
Size 2.0 MB
Tags Source
SHA-256 checksum
How to use checksums
39694b02804d5f88072077ab1ab5f622d6ccf1d3421ad80d7bfb7dac9acbdc51
BLAKE2b-256 checksum
How to use checksums
ca4d73a01376718d6bd901f14f5bffba5edce9705c8469889193d9564abc8c24
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

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 Jun 2, 2026.

Transparency log

Release files / supertokens-0.1.5-cp313-cp313-win_amd64.whl

Download URL supertokens-0.1.5-cp313-cp313-win_amd64.whl
Size 92.5 kB
Tags CPython 3.13 Windows x86-64
SHA-256 checksum
How to use checksums
cb5b819c5443ac7bb43f634a80a06723e40a24996cf36a334cf0ed31f1cc7c09
BLAKE2b-256 checksum
How to use checksums
621118927e03e3336e9925f8d1e3353a76e154f940252b9d21a5d2a2229f5250
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

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 Jun 2, 2026.

Transparency log

Release files / supertokens-0.1.5-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl

Download URL supertokens-0.1.5-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Size 169.9 kB
Tags CPython 3.13 Linux glibc 2.27+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
14c1a11e6b2c12db3dd7df0dce194d543ce3d2bf23ce0d7284f7e212a092d68a
BLAKE2b-256 checksum
How to use checksums
61ff70fc977c23893513164722c5cfbe957a43aea4e4d5ae974185f1e6547144
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

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 Jun 2, 2026.

Transparency log

Release files / supertokens-0.1.5-cp313-cp313-macosx_11_0_arm64.whl

Download URL supertokens-0.1.5-cp313-cp313-macosx_11_0_arm64.whl
Size 72.0 kB
Tags CPython 3.13 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
450f7cfca402489f541eb844ccd482182ce528c9948c64ef65d5ba47347512d7
BLAKE2b-256 checksum
How to use checksums
c120a09ebdb46a0b102c2ca8a22eb3e07123a6571c8d0561bfd845049a47af3a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

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 Jun 2, 2026.

Transparency log

Security for supertokens 0.1.5

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 4 files in this release have been uploaded with provenance metadata.

Select from 4 files

Attestation for supertokens-0.1.5.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 Jun 2, 2026.

Transparency log

A 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.

Release history Release notifications | RSS feed

This release

0.1.5 This release

4 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page