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.3.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.3.0
File Size Uploaded Provenance Actions
small_python-0.3.0.tar.gz 1.9 MB With provenance Details for small_python-0.3.0.tar.gz

Built distributions (wheels)

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

Total release size: 11.2 MB

Release files / small_python-0.3.0.tar.gz

Download URL small_python-0.3.0.tar.gz
Size 1.9 MB
Tags Source
SHA-256 checksum
How to use checksums
8f5ef339fdb5a05048a2e2ca9be44a73f3754784a8af05a2bda390d5cfbe2542
BLAKE2b-256 checksum
How to use checksums
32e2e39348b8aa3c92b26d94905f4813c415d3041c0b611fdd6396e6baf2d3d3
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 Oct 30, 2026.

Transparency log

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

Download URL small_python-0.3.0-py3-none-win_amd64.whl
Size 696.1 kB
Tags Python 3 Windows x86-64
SHA-256 checksum
How to use checksums
ab150c5021e382f4cf3bc46cbb8cfd7152ba136bd3ac8e6d885f4d0441d8ce23
BLAKE2b-256 checksum
How to use checksums
e2d0c7e95e040e0275f268a97e1a8430273a57609f7bab25b69d17ec2f37bcd0
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 Oct 30, 2026.

Transparency log

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

Download URL small_python-0.3.0-py3-none-musllinux_1_2_x86_64.whl
Size 1.8 MB
Tags Linux musl 1.2+ x86-64 Python 3
SHA-256 checksum
How to use checksums
79ae4b232cc2ae75112cf9408b5932feb25d5bf404002d5270baa3cd8ef58771
BLAKE2b-256 checksum
How to use checksums
399b23982585912c4b2c33c50ada7468212603f400dabc710c7948619305e6c3
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 Oct 30, 2026.

Transparency log

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

Download URL small_python-0.3.0-py3-none-musllinux_1_2_aarch64.whl
Size 1.8 MB
Tags Linux musl 1.2+ ARM64 Python 3
SHA-256 checksum
How to use checksums
2de965295095a518073198179aed67e61a4965c537ada2724d94c60da6fca646
BLAKE2b-256 checksum
How to use checksums
3b0c9efa764442b70c8d93c80be091a1d7df3e987d0028a8ebb72fde897c388b
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 Oct 30, 2026.

Transparency log

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

Download URL small_python-0.3.0-py3-none-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Size 1.8 MB
Tags Linux glibc 2.17+ x86-64 Linux glibc 2.28+ x86-64 Python 3
SHA-256 checksum
How to use checksums
30b401d107d147ef8c0f8f45581e650e2c8a975bd2fe2cf8dcac5a0725066c20
BLAKE2b-256 checksum
How to use checksums
ebf79647a3e29276b8ea8c941d5c5bf8b3b28257f328bb79db6ad2bf79d12f9d
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 Oct 30, 2026.

Transparency log

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

Download URL small_python-0.3.0-py3-none-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl
Size 1.8 MB
Tags Linux glibc 2.17+ ARM64 Linux glibc 2.28+ ARM64 Python 3
SHA-256 checksum
How to use checksums
2f9d5953aa08c65b3a5e35ed358779e921c2b5547995aff3a71e2c32f6a87e6c
BLAKE2b-256 checksum
How to use checksums
4241f0ce7d54a60397c784af913b20681c5ed7031ec1bb4ed4b29f9e4cb45af9
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 Oct 30, 2026.

Transparency log

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

Download URL small_python-0.3.0-py3-none-macosx_11_0_arm64.whl
Size 694.3 kB
Tags Python 3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
9e38775b3c0a5ccb6d4a6dbb2b1cd1c323fef602868b2aee0748a704d21c818a
BLAKE2b-256 checksum
How to use checksums
32b0da9f65043f3d4aa4539dd2367290c725ae465a0c0fe2efb110cf8947799c
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 Oct 30, 2026.

Transparency log

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

Download URL small_python-0.3.0-py3-none-macosx_10_13_x86_64.whl
Size 732.4 kB
Tags Python 3 macOS 10.13+ x86-64
SHA-256 checksum
How to use checksums
912d815a87355b406f9748bf4915546c9d4fbb08e71547baf61a529e4771d0bb
BLAKE2b-256 checksum
How to use checksums
66b4e58414563d95b88bc3b68f4900542554a2ae4a58a5f52ba3ec63f61eda9d
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 Oct 30, 2026.

Transparency log

Security for small-python 0.3.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.3.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 Oct 30, 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