serpentium
Drop-in performance accelerators for CPython, bundled.
pip install serpentium and several hot paths in the standard library transparently start running on faster native code — no code changes, and no import required: serpentium auto-enables at interpreter startup.
import random
from datetime import datetime
import html
deck = list(range(52))
random.shuffle(deck) # ~8x faster, served by Rust (randium)
datetime.strptime("2026-06-07", "%Y-%m-%d") # faster, fully stdlib-compatible (datetimium)
html.unescape("Tom & Jerry") # ~4x faster, served by Rust (htmlium)
Serpentium aims for every accelerator to be a true drop-in: same results, down to
error messages. CPython's own tests for the modules it touches pass with serpentium
installed (python tools/cpython_suite.py).
What's inside
| Element | Main target | Backend |
|---|---|---|
| randium | the random module — random(), randint/randrange/_randbelow, shuffle |
Rust |
| datetimium | datetime.strptime (locale-independent formats) |
Python |
| htmlium | html.escape, html.unescape (and HTMLParser, which calls unescape) |
Rust |
| floatium | repr(float), str(float), f"{x:.3f}", float(str) |
C++ (dep) |
| copium | copy.deepcopy |
dep |
randium, datetimium and htmlium ship inside serpentium; floatium and copium
are separately-maintained packages pulled in as dependencies.
Benchmarks
CPython 3.14, release build. serpentium wins where a whole Python loop moves to native code (shuffle, deepcopy, entity decoding); per-call primitives merely tie CPython's hand-tuned C (the honest story — see INTERNALS.md).
| Operation | stdlib | serpentium | speedup |
|---|---|---|---|
random.shuffle(list[1000]) |
158 µs | 19 µs | 8.3× |
copy.deepcopy (pyperformance bm_deepcopy) |
7.8 µs | 1.3 µs | 6.0× |
html.unescape (text with entities) |
4.3 µs | 0.95 µs | 4.5× |
html.escape (clean paragraph) |
208 ns | 62 ns | 3.3× |
datetime.strptime("%Y-%m-%d") |
3.77 µs | 1.54 µs | 2.4× |
f"{x:.3f}" (float formatting) |
348 ns | 160 ns | 2.2× |
datetime.strptime("%Y-%m-%d %H:%M:%S") |
4.67 µs | 2.75 µs | 1.7× |
random.sample(10k, 100) |
20.7 µs | 17.5 µs | 1.2× |
random.randint(1, 6) |
157 ns | 150 ns | 1.05× |
random.random() |
54 ns | 51 ns | 1.04× |
html.unescape (no entities) |
42 ns | 42 ns | 1.0× |
Control
Auto-enabled by default. To opt out:
SERPENTIUM_AUTOPATCH=0 python ... # per-process
python -m serpentium disable # persistent (writes a marker file)
python -m serpentium status # show what's active
Or drive it explicitly from code:
import serpentium
serpentium.install(randium=True, datetimium=True, htmlium=True) # toggle individually
serpentium.uninstall() # restore the stdlib
Documentation
Design, compatibility guarantees, the in-place-patching mechanism, the test strategy, and building from source are in INTERNALS.md.
License
Dual-licensed under either MIT or Apache-2.0, at your option.
Metadata
Release files for serpentium 0.0.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| serpentium-0.0.4.tar.gz | 65.2 kB | Details |
Built distributions (wheels)
Total release size: 2.8 MB
Release files / serpentium-0.0.4.tar.gz
| Download URL | serpentium-0.0.4.tar.gz |
|---|---|
| Size | 65.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
885dfb4d780a8931346d25fa20e7dd3695c74f8260fd599bb3a76a667fc72032
|
|
BLAKE2b-256 checksum How to use checksums |
ae23bdafe7ded91ae52d8e6e00897d662c11335ef6f0b6ac29aef390dac8fa3e
|
| 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 9, 2026.
Transparency logRelease files / serpentium-0.0.4-cp314-cp314-win_amd64.whl
| Download URL | serpentium-0.0.4-cp314-cp314-win_amd64.whl |
|---|---|
| Size | 182.5 kB |
| Tags | CPython 3.14 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
85cd3905f20735e2a84c52fca807827ada124fa150fdd14f0fd30350cbbb3445
|
|
BLAKE2b-256 checksum How to use checksums |
a81b1671e2f75c29cd123860609c885c6c67311cecbef5ff75ef77b375b27b70
|
| 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 9, 2026.
Transparency logRelease files / serpentium-0.0.4-cp314-cp314-manylinux_2_28_x86_64.whl
| Download URL | serpentium-0.0.4-cp314-cp314-manylinux_2_28_x86_64.whl |
|---|---|
| Size | 304.1 kB |
| Tags | CPython 3.14 Linux glibc 2.28+ x86-64 |
|
SHA-256 checksum How to use checksums |
336232675c4d077ecf2fcd349830e59c06fc9e6ee4bca9fee7d5b10553fa5edc
|
|
BLAKE2b-256 checksum How to use checksums |
5270a65abee1b2cbee6e2ae77d808972539aa43b4b84e77eff3509ae613f190c
|
| 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 9, 2026.
Transparency logRelease files / serpentium-0.0.4-cp314-cp314-manylinux_2_28_aarch64.whl
| Download URL | serpentium-0.0.4-cp314-cp314-manylinux_2_28_aarch64.whl |
|---|---|
| Size | 316.6 kB |
| Tags | CPython 3.14 Linux glibc 2.28+ ARM64 |
|
SHA-256 checksum How to use checksums |
b678910bdf0ebc8afd18960737001d6a9c97b641f8ffc6489275748011d6156a
|
|
BLAKE2b-256 checksum How to use checksums |
425fc506b9d1ed9cfd9bc2cfcd752ef397eaff22bf44421025079d3ae873e6f1
|
| 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 9, 2026.
Transparency logRelease files / serpentium-0.0.4-cp314-cp314-macosx_11_0_arm64.whl
| Download URL | serpentium-0.0.4-cp314-cp314-macosx_11_0_arm64.whl |
|---|---|
| Size | 270.5 kB |
| Tags | CPython 3.14 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
a427f4141056837cdcddf9f129a8e8400bb1c92dc87273c4abb3304565bb01c2
|
|
BLAKE2b-256 checksum How to use checksums |
bcc1e8588829694ed7fba05e051e66d66d7e88a2e96c194f88d9cfe02436689b
|
| 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 9, 2026.
Transparency logRelease files / serpentium-0.0.4-cp314-cp314-macosx_10_15_x86_64.whl
| Download URL | serpentium-0.0.4-cp314-cp314-macosx_10_15_x86_64.whl |
|---|---|
| Size | 279.8 kB |
| Tags | CPython 3.14 macOS 10.15+ x86-64 |
|
SHA-256 checksum How to use checksums |
625fa9b929bf7cbc768152996bbced2d416af9184743cc9f7b5607125610aef4
|
|
BLAKE2b-256 checksum How to use checksums |
b11881ce56e24461e5efb016a6ffc44f5f8395b2c0c17533d86da71a66a41fa4
|
| 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 9, 2026.
Transparency logRelease files / serpentium-0.0.4-cp313-cp313-win_amd64.whl
| Download URL | serpentium-0.0.4-cp313-cp313-win_amd64.whl |
|---|---|
| Size | 182.7 kB |
| Tags | CPython 3.13 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
699b7c531c8a4248dcb81a3225d349d1961080f75598ec24f300333e1c866733
|
|
BLAKE2b-256 checksum How to use checksums |
500eca171d9b03295303993fdbfe389c476e285266748f1a19dda4c093992278
|
| 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 9, 2026.
Transparency logRelease files / serpentium-0.0.4-cp313-cp313-manylinux_2_28_x86_64.whl
| Download URL | serpentium-0.0.4-cp313-cp313-manylinux_2_28_x86_64.whl |
|---|---|
| Size | 304.4 kB |
| Tags | CPython 3.13 Linux glibc 2.28+ x86-64 |
|
SHA-256 checksum How to use checksums |
3b8545018a80e318832c70b0f6d7413cd30acacb07b6a34e59cc530dfe770e1b
|
|
BLAKE2b-256 checksum How to use checksums |
474eebcefff72654502ed916063c450b4e43e98f97005b4f184da819f524dca8
|
| 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 9, 2026.
Transparency logRelease files / serpentium-0.0.4-cp313-cp313-manylinux_2_28_aarch64.whl
| Download URL | serpentium-0.0.4-cp313-cp313-manylinux_2_28_aarch64.whl |
|---|---|
| Size | 317.1 kB |
| Tags | CPython 3.13 Linux glibc 2.28+ ARM64 |
|
SHA-256 checksum How to use checksums |
119599401ca29a49ef4f6c92dc3e17b22da4cdd94e12469712593d4b26296c26
|
|
BLAKE2b-256 checksum How to use checksums |
490ac804847c1f39f992bc93e30c2b61083bc1a5666e774be1d0d6e4297ff609
|
| 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 9, 2026.
Transparency logRelease files / serpentium-0.0.4-cp313-cp313-macosx_11_0_arm64.whl
| Download URL | serpentium-0.0.4-cp313-cp313-macosx_11_0_arm64.whl |
|---|---|
| Size | 270.9 kB |
| Tags | CPython 3.13 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
e646a464b06d7ec31a5ddc7442647f4f1ad38e2303c2b859c3889e64e63cfd38
|
|
BLAKE2b-256 checksum How to use checksums |
2dbad2bb894a8dc00417fcff507db47cf746b45f6550cc13e68451096461e428
|
| 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 9, 2026.
Transparency logRelease files / serpentium-0.0.4-cp313-cp313-macosx_10_13_x86_64.whl
| Download URL | serpentium-0.0.4-cp313-cp313-macosx_10_13_x86_64.whl |
|---|---|
| Size | 280.1 kB |
| Tags | CPython 3.13 macOS 10.13+ x86-64 |
|
SHA-256 checksum How to use checksums |
168bd6ffe60d367483323a0f3e35b98aaba5a9db132727c797cf7a0e184794c3
|
|
BLAKE2b-256 checksum How to use checksums |
186eeb58ae6b59bd57b56d3c4dd1c8f9b96abf93bd01d0d84c4dabb96dddeb23
|
| 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 9, 2026.
Transparency log