Skip to main content

Small Python

Small Python is a small and embeddable Python runtime. This package, small-python, runs it from CPython: create isolated interpreters, run code in them, and give that code exactly the functions, modules, and files you choose.

logo

Features

  • Small, just a few C files, no external dependencies.
  • No Python Libs. Attach your own modules.
  • Almost complete Python 3.15 support.
  • Run code generated by AI against only the functions you expose.
  • Each runtime runs in its own worker process: an engine crash raises an exception instead of taking down your program.
  • Limits on steps, memory, time, and message size.
  • Can compile Python code to executables with no external dependency.
  • GC uses reference counting with cycle removal.

Install

pip install small-python

Requires CPython 3.10 or newer on Linux, macOS, or Windows (x86_64).

Example

import small_python

with small_python.Runtime(step_limit=1_000_000, memory_limit=64 << 20, timeout=5) as rt:
    @rt.function
    def fetch(key, *, default=None):
        return {"answer": 42}.get(key, default)

    rt.register_module("host", {"fetch": fetch}, source="def twice(n): return n * 2")
    rt.exec("from host import twice")
    print(rt.eval("twice(fetch('answer'))"))  # 84

Documentation

Build

Requires a C11 compiler. Manage the project with uv:

uv sync --locked
uv run python -c "import small_python"
uv build

See Development for tests and the release process.

Metadata

Release files for small-python 0.7.0

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

Source distribution (sdist)

Source distribution for small-python 0.7.0
File Size Uploaded Provenance Actions
small_python-0.7.0.tar.gz 2.0 MB With provenance Details for small_python-0.7.0.tar.gz

Built distributions (wheels)

Table of built distributions (wheels) for small-python 0.7.0
File Actions
small_python-0.7.0-py3-none-win_amd64.whl Python 3 none Windows x86-64 Details for small_python-0.7.0-py3-none-win_amd64.whl
small_python-0.7.0-py3-none-musllinux_1_2_x86_64.whl Python 3 none Linux musl 1.2+ x86-64 Details for small_python-0.7.0-py3-none-musllinux_1_2_x86_64.whl
small_python-0.7.0-py3-none-musllinux_1_2_aarch64.whl Python 3 none Linux musl 1.2+ ARM64 Details for small_python-0.7.0-py3-none-musllinux_1_2_aarch64.whl
small_python-0.7.0-py3-none-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl Python 3 none Linux glibc 2.17+ x86-64, Linux glibc 2.28+ x86-64 Details for small_python-0.7.0-py3-none-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
small_python-0.7.0-py3-none-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl Python 3 none Linux glibc 2.28+ ARM64, Linux glibc 2.17+ ARM64 Details for small_python-0.7.0-py3-none-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl
small_python-0.7.0-py3-none-macosx_11_0_arm64.whl Python 3 none macOS 11.0+ ARM64 Details for small_python-0.7.0-py3-none-macosx_11_0_arm64.whl
small_python-0.7.0-py3-none-macosx_10_13_x86_64.whl Python 3 none macOS 10.13+ x86-64 Details for small_python-0.7.0-py3-none-macosx_10_13_x86_64.whl

Total release size: 12.5 MB

Release files / small_python-0.7.0.tar.gz

Download URL small_python-0.7.0.tar.gz
Size 2.0 MB
Tags Source
SHA-256 checksum
How to use checksums
546b0947fe4cb6ffbe3df73e39cd3ee27ab670b0e2e5b4e95c5935de7a899452
BLAKE2b-256 checksum
How to use checksums
1df903524ae9b458fc8df80bf2c55abd1f2fe5951a91a81ee864326b81f04ace
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Nov 4, 2026.

Transparency log

Release files / small_python-0.7.0-py3-none-win_amd64.whl

Download URL small_python-0.7.0-py3-none-win_amd64.whl
Size 765.3 kB
Tags Python 3 Windows x86-64
SHA-256 checksum
How to use checksums
1858b47ea65809929e0efdd8c78c1c7c14cc3b850f9fa37c57ee20cd4edc1c88
BLAKE2b-256 checksum
How to use checksums
2058aee602d813dcfacb3ce8887e68c2157ecc0a10c057eb0e616d2118c1686b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Nov 4, 2026.

Transparency log

Release files / small_python-0.7.0-py3-none-musllinux_1_2_x86_64.whl

Download URL small_python-0.7.0-py3-none-musllinux_1_2_x86_64.whl
Size 2.1 MB
Tags Linux musl 1.2+ x86-64 Python 3
SHA-256 checksum
How to use checksums
43189a98d675b8b9dd6ed4c99f6631e0d0aa5646b06aa5fa15b6743850872c9d
BLAKE2b-256 checksum
How to use checksums
1c9d64698c2e01e67b81b4588ad2e7b0d552aafbec3bce3bde3de11dec7aa5c7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Nov 4, 2026.

Transparency log

Release files / small_python-0.7.0-py3-none-musllinux_1_2_aarch64.whl

Download URL small_python-0.7.0-py3-none-musllinux_1_2_aarch64.whl
Size 2.1 MB
Tags Linux musl 1.2+ ARM64 Python 3
SHA-256 checksum
How to use checksums
0be4921797b02ea8fb47bfc5e602e6b8673d8bc1a314afd9a165c14175393d51
BLAKE2b-256 checksum
How to use checksums
58e4a24e830c5f39a970c733cca0ceb67ce3486bafa95e0db0954dd219aa7561
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Nov 4, 2026.

Transparency log

Release files / small_python-0.7.0-py3-none-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl

Download URL small_python-0.7.0-py3-none-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Size 2.1 MB
Tags Linux glibc 2.17+ x86-64 Linux glibc 2.28+ x86-64 Python 3
SHA-256 checksum
How to use checksums
eac329a1bf0f92de7725a3aa134d3ff2b90ca9d2f4ed62c090316249c6c9c88a
BLAKE2b-256 checksum
How to use checksums
2956a3775341f3dbcb2aa9945853947e2547afab0cf5a3c992fa727bd1f53c73
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Nov 4, 2026.

Transparency log

Release files / small_python-0.7.0-py3-none-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl

Download URL small_python-0.7.0-py3-none-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl
Size 2.0 MB
Tags Linux glibc 2.17+ ARM64 Linux glibc 2.28+ ARM64 Python 3
SHA-256 checksum
How to use checksums
3b55ff30428d527f01d73b992f240d3d547b993cc93d12d758fef6482649a0bf
BLAKE2b-256 checksum
How to use checksums
0f6bf260b23169f8153ac81a96437837a4bb1b598120307427eab0b5698e593b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Nov 4, 2026.

Transparency log

Release files / small_python-0.7.0-py3-none-macosx_11_0_arm64.whl

Download URL small_python-0.7.0-py3-none-macosx_11_0_arm64.whl
Size 746.7 kB
Tags Python 3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
9dbb322b8613557476ba26e14d70cdf73c8cf28f53a0eb188a2a6b7d8368fbf0
BLAKE2b-256 checksum
How to use checksums
fa1299bab73d74838878ccc5c9f3ecf0c7e3b1f7db65e94d6581821ea4f98ab9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Nov 4, 2026.

Transparency log

Release files / small_python-0.7.0-py3-none-macosx_10_13_x86_64.whl

Download URL small_python-0.7.0-py3-none-macosx_10_13_x86_64.whl
Size 800.3 kB
Tags Python 3 macOS 10.13+ x86-64
SHA-256 checksum
How to use checksums
c2b9d2038816e50d82847d6cfb148e857a994e2bf8ab0225cd409add92613322
BLAKE2b-256 checksum
How to use checksums
2cad03cc1c2ff1f9e5e1b94fec4e77931f013e67a17a9cdf8b1aa2bf663874c9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Nov 4, 2026.

Transparency log

Security for small-python 0.7.0

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

Select from 8 files

Attestation for small_python-0.7.0.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 Nov 4, 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.

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