Skip to main content

Compiled versions of the Python standard library.

Project description

compiled

Compiled variants of the Python standard library.

What is this project exactly?

Pure Python modules in the standard library can be a speed bottleneck sometimes, this package aims to provide "compiled" variants of the pure Python standard library modules, which are somewhere between 2-4x faster than the builtin ones.

Installation

pip install compiled

✨ This will install the pycompile CLI script as well.

Usage

Say your program asd.py looks like this:

import tomllib
from difflib import get_close_matches

# ... rest of the code

You can use the bundled pycompile script to turn those imports into the "compiled" variants:

$ pycompile asd.py
 Rewrote asd.py with compiled imports.

$ cat asd.py
import compiled.tomllib as tomllib
from compiled.difflib import get_close_matches

# ... rest of the code

With a real world program using tomllib and difflib, we get the following difference in speed:

Program Pure Python time compiled time Speedup %
hashes.py 1.907 seconds 1.028 seconds 85.5% faster

Local Development / Testing

  • Create and activate a virtual environment.

  • Run pip install mypy, as mypy[c] is the only dependency.

  • Scripts to test, build and package standard libraries are present in build.py:

    $ ./build.py test tomllib
    .............
    ----------------------------------------------------------------------
    Ran 13 tests in 0.006s
    OK
    
    $ ./build.py mypy tomllib
    Success: no issues found in 4 source files
    
    $ ./build.py package
    [...]
    ✨Built ./build/dist/compiled-0.2.1-cp311-cp311-macosx_13_0_arm64.whl
    
  • Run pytest compiled_tests to run tests.

Project details


Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

compiled-0.3.0-cp312-cp312-win_amd64.whl (282.2 kB view hashes)

Uploaded CPython 3.12 Windows x86-64

compiled-0.3.0-cp312-cp312-win32.whl (244.8 kB view hashes)

Uploaded CPython 3.12 Windows x86

compiled-0.3.0-cp312-cp312-musllinux_1_1_x86_64.whl (630.1 kB view hashes)

Uploaded CPython 3.12 musllinux: musl 1.1+ x86-64

compiled-0.3.0-cp312-cp312-musllinux_1_1_i686.whl (650.7 kB view hashes)

Uploaded CPython 3.12 musllinux: musl 1.1+ i686

compiled-0.3.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (641.9 kB view hashes)

Uploaded CPython 3.12 manylinux: glibc 2.17+ x86-64

compiled-0.3.0-cp312-cp312-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl (664.1 kB view hashes)

Uploaded CPython 3.12 manylinux: glibc 2.17+ i686 manylinux: glibc 2.5+ i686

compiled-0.3.0-cp312-cp312-macosx_10_9_x86_64.whl (372.4 kB view hashes)

Uploaded CPython 3.12 macOS 10.9+ x86-64

compiled-0.3.0-cp311-cp311-win_amd64.whl (281.7 kB view hashes)

Uploaded CPython 3.11 Windows x86-64

compiled-0.3.0-cp311-cp311-win32.whl (241.5 kB view hashes)

Uploaded CPython 3.11 Windows x86

compiled-0.3.0-cp311-cp311-musllinux_1_1_x86_64.whl (601.5 kB view hashes)

Uploaded CPython 3.11 musllinux: musl 1.1+ x86-64

compiled-0.3.0-cp311-cp311-musllinux_1_1_i686.whl (604.2 kB view hashes)

Uploaded CPython 3.11 musllinux: musl 1.1+ i686

compiled-0.3.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (616.4 kB view hashes)

Uploaded CPython 3.11 manylinux: glibc 2.17+ x86-64

compiled-0.3.0-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl (621.0 kB view hashes)

Uploaded CPython 3.11 manylinux: glibc 2.17+ i686 manylinux: glibc 2.5+ i686

compiled-0.3.0-cp311-cp311-macosx_10_9_x86_64.whl (365.7 kB view hashes)

Uploaded CPython 3.11 macOS 10.9+ x86-64

Supported by

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