Skip to main content

Drop-in performance accelerators for CPython, bundled. floatium + copium + randium.

Project description

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

serpentium-0.0.3.tar.gz (65.2 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

serpentium-0.0.3-cp314-cp314-win_amd64.whl (182.5 kB view details)

Uploaded CPython 3.14Windows x86-64

serpentium-0.0.3-cp314-cp314-manylinux_2_28_x86_64.whl (303.8 kB view details)

Uploaded CPython 3.14manylinux: glibc 2.28+ x86-64

serpentium-0.0.3-cp314-cp314-manylinux_2_28_aarch64.whl (316.4 kB view details)

Uploaded CPython 3.14manylinux: glibc 2.28+ ARM64

serpentium-0.0.3-cp314-cp314-macosx_11_0_arm64.whl (270.3 kB view details)

Uploaded CPython 3.14macOS 11.0+ ARM64

serpentium-0.0.3-cp314-cp314-macosx_10_15_x86_64.whl (279.5 kB view details)

Uploaded CPython 3.14macOS 10.15+ x86-64

serpentium-0.0.3-cp313-cp313-win_amd64.whl (182.6 kB view details)

Uploaded CPython 3.13Windows x86-64

serpentium-0.0.3-cp313-cp313-manylinux_2_28_x86_64.whl (304.1 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.28+ x86-64

serpentium-0.0.3-cp313-cp313-manylinux_2_28_aarch64.whl (316.8 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.28+ ARM64

serpentium-0.0.3-cp313-cp313-macosx_11_0_arm64.whl (270.6 kB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

serpentium-0.0.3-cp313-cp313-macosx_10_13_x86_64.whl (279.8 kB view details)

Uploaded CPython 3.13macOS 10.13+ x86-64

File details

Details for the file serpentium-0.0.3.tar.gz.

File metadata

  • Download URL: serpentium-0.0.3.tar.gz
  • Upload date:
  • Size: 65.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for serpentium-0.0.3.tar.gz
Algorithm Hash digest
SHA256 846c84aa9e1fbe3205164bd2130de3e832adcb02436b6f8454f1572b66923745
MD5 33a30cb0d41dd69be35715bf6760559b
BLAKE2b-256 a7209ad5581db8a333ee87c0af3d9a8d2b72ac0658fc155cb082a40ed156e3e8

See more details on using hashes here.

Provenance

The following attestation bundles were made for serpentium-0.0.3.tar.gz:

Publisher: release.yml on eendebakpt/serpentium

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file serpentium-0.0.3-cp314-cp314-win_amd64.whl.

File metadata

  • Download URL: serpentium-0.0.3-cp314-cp314-win_amd64.whl
  • Upload date:
  • Size: 182.5 kB
  • Tags: CPython 3.14, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for serpentium-0.0.3-cp314-cp314-win_amd64.whl
Algorithm Hash digest
SHA256 64bd16e1a41b58c8926f342dac8e2ffbe8257464b90167234fffddd5c8f5003a
MD5 b2bcf107e191e7666948c2dcb6cb3cfa
BLAKE2b-256 0d88010373c2e8c5adf44f12d4521c6430d1be2fa5438e41ad89b760f370cbf7

See more details on using hashes here.

Provenance

The following attestation bundles were made for serpentium-0.0.3-cp314-cp314-win_amd64.whl:

Publisher: release.yml on eendebakpt/serpentium

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file serpentium-0.0.3-cp314-cp314-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for serpentium-0.0.3-cp314-cp314-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 197bc633b4a032e48a093d342d11cdf2a6ef1367736e29371d75f2e689d55e4d
MD5 68b81aa99a5572c6de6640acb1b3aa51
BLAKE2b-256 e80c28fb7e51d42e5e28ac322e654aabe2a2aa4da99e3631c6a89d542b309f97

See more details on using hashes here.

Provenance

The following attestation bundles were made for serpentium-0.0.3-cp314-cp314-manylinux_2_28_x86_64.whl:

Publisher: release.yml on eendebakpt/serpentium

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file serpentium-0.0.3-cp314-cp314-manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for serpentium-0.0.3-cp314-cp314-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 d6690398a89862abae4fb171c603cdd0cda95b4b67748a2faff9ad15da232dae
MD5 ef39b1fc27b31f3bfbc3bce7e0845874
BLAKE2b-256 02f6022ec2314177c0469dc927a4a2caf0a8db2e119e659654db656550d41369

See more details on using hashes here.

Provenance

The following attestation bundles were made for serpentium-0.0.3-cp314-cp314-manylinux_2_28_aarch64.whl:

Publisher: release.yml on eendebakpt/serpentium

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file serpentium-0.0.3-cp314-cp314-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for serpentium-0.0.3-cp314-cp314-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 95c9e04fa6e3578ea351620cabe28d4ffb737451799ed88db96ef5242dea59cd
MD5 991b3464bd05eec74f9c27ee29344a59
BLAKE2b-256 51c4bc3e652cc17540061ba84fdd3b8233fcebaa0b2dc8967a7885fa82146954

See more details on using hashes here.

Provenance

The following attestation bundles were made for serpentium-0.0.3-cp314-cp314-macosx_11_0_arm64.whl:

Publisher: release.yml on eendebakpt/serpentium

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file serpentium-0.0.3-cp314-cp314-macosx_10_15_x86_64.whl.

File metadata

File hashes

Hashes for serpentium-0.0.3-cp314-cp314-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 041e0643f9eac74bdcfb0b82233efea77b18b5b801b061d6860ebd3f1f5888f6
MD5 fe3072a99cc676265df68b855894bdb1
BLAKE2b-256 4e05274cc131867a0a909792d7133b6cca08a541b56cf09ed36922c8ffe3b983

See more details on using hashes here.

Provenance

The following attestation bundles were made for serpentium-0.0.3-cp314-cp314-macosx_10_15_x86_64.whl:

Publisher: release.yml on eendebakpt/serpentium

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file serpentium-0.0.3-cp313-cp313-win_amd64.whl.

File metadata

  • Download URL: serpentium-0.0.3-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 182.6 kB
  • Tags: CPython 3.13, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for serpentium-0.0.3-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 cb07cbca8105876a22c706fae1dc5116c89b1bfb3830ab0b4f58c29fe81cb774
MD5 1ae24313046bdf9bac68042761ed5f7b
BLAKE2b-256 d02f81c323f869c4a512ece7273efe9031e593f2c1f1448770ac7beb63f907ff

See more details on using hashes here.

Provenance

The following attestation bundles were made for serpentium-0.0.3-cp313-cp313-win_amd64.whl:

Publisher: release.yml on eendebakpt/serpentium

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file serpentium-0.0.3-cp313-cp313-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for serpentium-0.0.3-cp313-cp313-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 e98a3cdecb7f4d429a3558b2ec4c84a5bf4feda3f0b095494b3a62e491b2b2bb
MD5 038e90865b533b28cd1c2812933df7bb
BLAKE2b-256 8be4d90a036c32780b94434f0a663e65c3b9c3eed2982586a3de395ecb5aed53

See more details on using hashes here.

Provenance

The following attestation bundles were made for serpentium-0.0.3-cp313-cp313-manylinux_2_28_x86_64.whl:

Publisher: release.yml on eendebakpt/serpentium

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file serpentium-0.0.3-cp313-cp313-manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for serpentium-0.0.3-cp313-cp313-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 24ebd69895153c8539ba5be2730aa6b5742eee18e39f77aa9404825840a5d1e6
MD5 77f9edfb9fe9a514a2bcd656bdd77555
BLAKE2b-256 bdb0b744d49ad6242cca6e57334352573b25490709f7eb20c4e8273a26373ff0

See more details on using hashes here.

Provenance

The following attestation bundles were made for serpentium-0.0.3-cp313-cp313-manylinux_2_28_aarch64.whl:

Publisher: release.yml on eendebakpt/serpentium

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file serpentium-0.0.3-cp313-cp313-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for serpentium-0.0.3-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 28df3ff33eb002d7d80a618553cb1455838fc377f2ce48612c02f23b7c6c841f
MD5 6b900d7998fa98b950278cb335a955ee
BLAKE2b-256 5fe1a304bf857148617420480ea023016cb0549cda289d63eda9c4e0f8f67d1a

See more details on using hashes here.

Provenance

The following attestation bundles were made for serpentium-0.0.3-cp313-cp313-macosx_11_0_arm64.whl:

Publisher: release.yml on eendebakpt/serpentium

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file serpentium-0.0.3-cp313-cp313-macosx_10_13_x86_64.whl.

File metadata

File hashes

Hashes for serpentium-0.0.3-cp313-cp313-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 c5fc18dffed4c8f9694325643662a0639c9bc0b55706e7ed7ba2f67aa6a6d218
MD5 84f21a3ebf29e819c359f9c161693c4a
BLAKE2b-256 03f466aae883ef31959ca4694d289dd3d2ec17e593035577a4f750598965a8a2

See more details on using hashes here.

Provenance

The following attestation bundles were made for serpentium-0.0.3-cp313-cp313-macosx_10_13_x86_64.whl:

Publisher: release.yml on eendebakpt/serpentium

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page