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.4.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.4-cp314-cp314-win_amd64.whl (182.5 kB view details)

Uploaded CPython 3.14Windows x86-64

serpentium-0.0.4-cp314-cp314-manylinux_2_28_x86_64.whl (304.1 kB view details)

Uploaded CPython 3.14manylinux: glibc 2.28+ x86-64

serpentium-0.0.4-cp314-cp314-manylinux_2_28_aarch64.whl (316.6 kB view details)

Uploaded CPython 3.14manylinux: glibc 2.28+ ARM64

serpentium-0.0.4-cp314-cp314-macosx_11_0_arm64.whl (270.5 kB view details)

Uploaded CPython 3.14macOS 11.0+ ARM64

serpentium-0.0.4-cp314-cp314-macosx_10_15_x86_64.whl (279.8 kB view details)

Uploaded CPython 3.14macOS 10.15+ x86-64

serpentium-0.0.4-cp313-cp313-win_amd64.whl (182.7 kB view details)

Uploaded CPython 3.13Windows x86-64

serpentium-0.0.4-cp313-cp313-manylinux_2_28_x86_64.whl (304.4 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.28+ x86-64

serpentium-0.0.4-cp313-cp313-manylinux_2_28_aarch64.whl (317.1 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.28+ ARM64

serpentium-0.0.4-cp313-cp313-macosx_11_0_arm64.whl (270.9 kB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

serpentium-0.0.4-cp313-cp313-macosx_10_13_x86_64.whl (280.1 kB view details)

Uploaded CPython 3.13macOS 10.13+ x86-64

File details

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

File metadata

  • Download URL: serpentium-0.0.4.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.4.tar.gz
Algorithm Hash digest
SHA256 885dfb4d780a8931346d25fa20e7dd3695c74f8260fd599bb3a76a667fc72032
MD5 016cdb09dd7773838b4d55841a2c7c3f
BLAKE2b-256 ae23bdafe7ded91ae52d8e6e00897d662c11335ef6f0b6ac29aef390dac8fa3e

See more details on using hashes here.

Provenance

The following attestation bundles were made for serpentium-0.0.4.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.4-cp314-cp314-win_amd64.whl.

File metadata

  • Download URL: serpentium-0.0.4-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.4-cp314-cp314-win_amd64.whl
Algorithm Hash digest
SHA256 85cd3905f20735e2a84c52fca807827ada124fa150fdd14f0fd30350cbbb3445
MD5 e099b5ac00bf809b94c57efc73d622e5
BLAKE2b-256 a81b1671e2f75c29cd123860609c885c6c67311cecbef5ff75ef77b375b27b70

See more details on using hashes here.

Provenance

The following attestation bundles were made for serpentium-0.0.4-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.4-cp314-cp314-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for serpentium-0.0.4-cp314-cp314-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 336232675c4d077ecf2fcd349830e59c06fc9e6ee4bca9fee7d5b10553fa5edc
MD5 8cd09fdcef8243d2095353b3a963d757
BLAKE2b-256 5270a65abee1b2cbee6e2ae77d808972539aa43b4b84e77eff3509ae613f190c

See more details on using hashes here.

Provenance

The following attestation bundles were made for serpentium-0.0.4-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.4-cp314-cp314-manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for serpentium-0.0.4-cp314-cp314-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 b678910bdf0ebc8afd18960737001d6a9c97b641f8ffc6489275748011d6156a
MD5 367f98417a81683145b3fe9c322aafcc
BLAKE2b-256 425fc506b9d1ed9cfd9bc2cfcd752ef397eaff22bf44421025079d3ae873e6f1

See more details on using hashes here.

Provenance

The following attestation bundles were made for serpentium-0.0.4-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.4-cp314-cp314-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for serpentium-0.0.4-cp314-cp314-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 a427f4141056837cdcddf9f129a8e8400bb1c92dc87273c4abb3304565bb01c2
MD5 0ce2ca0f27f48f49e280fa1a90993b9c
BLAKE2b-256 bcc1e8588829694ed7fba05e051e66d66d7e88a2e96c194f88d9cfe02436689b

See more details on using hashes here.

Provenance

The following attestation bundles were made for serpentium-0.0.4-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.4-cp314-cp314-macosx_10_15_x86_64.whl.

File metadata

File hashes

Hashes for serpentium-0.0.4-cp314-cp314-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 625fa9b929bf7cbc768152996bbced2d416af9184743cc9f7b5607125610aef4
MD5 4d49f7ed16beeead0b514580e4e4a31b
BLAKE2b-256 b11881ce56e24461e5efb016a6ffc44f5f8395b2c0c17533d86da71a66a41fa4

See more details on using hashes here.

Provenance

The following attestation bundles were made for serpentium-0.0.4-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.4-cp313-cp313-win_amd64.whl.

File metadata

  • Download URL: serpentium-0.0.4-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 182.7 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.4-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 699b7c531c8a4248dcb81a3225d349d1961080f75598ec24f300333e1c866733
MD5 43245663689664ee5ddb942793057939
BLAKE2b-256 500eca171d9b03295303993fdbfe389c476e285266748f1a19dda4c093992278

See more details on using hashes here.

Provenance

The following attestation bundles were made for serpentium-0.0.4-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.4-cp313-cp313-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for serpentium-0.0.4-cp313-cp313-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 3b8545018a80e318832c70b0f6d7413cd30acacb07b6a34e59cc530dfe770e1b
MD5 375ac525455d3af880d158474c9ff495
BLAKE2b-256 474eebcefff72654502ed916063c450b4e43e98f97005b4f184da819f524dca8

See more details on using hashes here.

Provenance

The following attestation bundles were made for serpentium-0.0.4-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.4-cp313-cp313-manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for serpentium-0.0.4-cp313-cp313-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 119599401ca29a49ef4f6c92dc3e17b22da4cdd94e12469712593d4b26296c26
MD5 6e4064ae2b05b186f4a0ce0fbe2792ff
BLAKE2b-256 490ac804847c1f39f992bc93e30c2b61083bc1a5666e774be1d0d6e4297ff609

See more details on using hashes here.

Provenance

The following attestation bundles were made for serpentium-0.0.4-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.4-cp313-cp313-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for serpentium-0.0.4-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 e646a464b06d7ec31a5ddc7442647f4f1ad38e2303c2b859c3889e64e63cfd38
MD5 ffb1020f7caae6108bcbbdc12c466371
BLAKE2b-256 2dbad2bb894a8dc00417fcff507db47cf746b45f6550cc13e68451096461e428

See more details on using hashes here.

Provenance

The following attestation bundles were made for serpentium-0.0.4-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.4-cp313-cp313-macosx_10_13_x86_64.whl.

File metadata

File hashes

Hashes for serpentium-0.0.4-cp313-cp313-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 168bd6ffe60d367483323a0f3e35b98aaba5a9db132727c797cf7a0e184794c3
MD5 ff01c861034e9edea7e47c51d296b0cd
BLAKE2b-256 186eeb58ae6b59bd57b56d3c4dd1c8f9b96abf93bd01d0d84c4dabb96dddeb23

See more details on using hashes here.

Provenance

The following attestation bundles were made for serpentium-0.0.4-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