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.8.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.8.0
File Size Uploaded Provenance Actions
small_python-0.8.0.tar.gz 2.0 MB With provenance Details for small_python-0.8.0.tar.gz

Built distributions (wheels)

Table of built distributions (wheels) for small-python 0.8.0
File Actions
small_python-0.8.0-py3-none-win_amd64.whl Python 3 none Windows x86-64 Details for small_python-0.8.0-py3-none-win_amd64.whl
small_python-0.8.0-py3-none-musllinux_1_2_x86_64.whl Python 3 none Linux musl 1.2+ x86-64 Details for small_python-0.8.0-py3-none-musllinux_1_2_x86_64.whl
small_python-0.8.0-py3-none-musllinux_1_2_aarch64.whl Python 3 none Linux musl 1.2+ ARM64 Details for small_python-0.8.0-py3-none-musllinux_1_2_aarch64.whl
small_python-0.8.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.8.0-py3-none-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
small_python-0.8.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.8.0-py3-none-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl
small_python-0.8.0-py3-none-macosx_11_0_arm64.whl Python 3 none macOS 11.0+ ARM64 Details for small_python-0.8.0-py3-none-macosx_11_0_arm64.whl
small_python-0.8.0-py3-none-macosx_10_13_x86_64.whl Python 3 none macOS 10.13+ x86-64 Details for small_python-0.8.0-py3-none-macosx_10_13_x86_64.whl

Total release size: 12.6 MB

Release files / small_python-0.8.0.tar.gz

Download URL small_python-0.8.0.tar.gz
Size 2.0 MB
Tags Source
SHA-256 checksum
How to use checksums
9d6f06bdb015953d30665cdde028acf99036bffe63d9d7ff373a0511c697dedf
BLAKE2b-256 checksum
How to use checksums
48113384ab5d79f324b3241fe23f9bab075c9c96304250e54161563bc8284012
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 5, 2026.

Transparency log

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

Download URL small_python-0.8.0-py3-none-win_amd64.whl
Size 767.5 kB
Tags Python 3 Windows x86-64
SHA-256 checksum
How to use checksums
88ce6e09436a34f19275f63c69da3afe92e78bb1d4bd52ec23f85c8ea4ea49db
BLAKE2b-256 checksum
How to use checksums
3773de3b86f440ca4a1d0d1bb79de4a33a842be1dbe5bd44806915cb254be8ae
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 5, 2026.

Transparency log

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

Download URL small_python-0.8.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
85624b2298e79afe7d5cb5450c9ee4cf1b3f6ca74a64f5df5907474faf4b060e
BLAKE2b-256 checksum
How to use checksums
fb822b96626b77ac606844c67f97bf99e1f7b75812a4e0d4555b9cb2d82d99c9
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 5, 2026.

Transparency log

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

Download URL small_python-0.8.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
7786aedbdc4103d44d6bcef240f195b7cde6c00f871ab810afa9ee0df49deb64
BLAKE2b-256 checksum
How to use checksums
1ed345214ace993f038f581caa97baa50425c74347dea5b618082ef69046258a
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 5, 2026.

Transparency log

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

Download URL small_python-0.8.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
5673e4e2e4420796ce7fd03d37895f4557077d93d74bac88dcbd79e32e3137ef
BLAKE2b-256 checksum
How to use checksums
d9a3626f53ffe262c7e2da5e07ed3626388c48262f2db011cfe47cf53d59dffe
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 5, 2026.

Transparency log

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

Download URL small_python-0.8.0-py3-none-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl
Size 2.1 MB
Tags Linux glibc 2.17+ ARM64 Linux glibc 2.28+ ARM64 Python 3
SHA-256 checksum
How to use checksums
0cef9aeeaaba28e13ea7a6932de2fccc096232643e28c909271571325f2b9322
BLAKE2b-256 checksum
How to use checksums
c93e8cc9bdece8bd9d34d4af11b0979aa60ebde1fcfc7313b39f8db16101fc46
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 5, 2026.

Transparency log

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

Download URL small_python-0.8.0-py3-none-macosx_11_0_arm64.whl
Size 750.3 kB
Tags Python 3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
6a950f75da329553b7cbc6330a9c7ae1540ce78593eedf5dc9b820048ef22fad
BLAKE2b-256 checksum
How to use checksums
53605a8ba5db9558751fa0094679a67f64a21f79f32b66d3e402b63eb205140b
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 5, 2026.

Transparency log

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

Download URL small_python-0.8.0-py3-none-macosx_10_13_x86_64.whl
Size 802.5 kB
Tags Python 3 macOS 10.13+ x86-64
SHA-256 checksum
How to use checksums
8ead7f4a7a04a681153d486246a8ef9f8d040dadeebed7f3ac9dc377bd789be4
BLAKE2b-256 checksum
How to use checksums
8ffd4293bf1f4d2010b929a2a24d77a13362b61d1cac2dd385eb925f5c72b8f7
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 5, 2026.

Transparency log

Security for small-python 0.8.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.8.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 5, 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