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.5.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.5.0
File Size Uploaded Provenance Actions
small_python-0.5.0.tar.gz 2.0 MB With provenance Details for small_python-0.5.0.tar.gz

Built distributions (wheels)

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

Total release size: 12.4 MB

Release files / small_python-0.5.0.tar.gz

Download URL small_python-0.5.0.tar.gz
Size 2.0 MB
Tags Source
SHA-256 checksum
How to use checksums
17c427f7ac2afd6d4c2107817a34e12e348e6b3d08499b5521f1dcae70dd1495
BLAKE2b-256 checksum
How to use checksums
28cd91095593a253d50883f4c9354bd022bde90a17f9d47cec00d12421ce0cb3
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 2, 2026.

Transparency log

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

Download URL small_python-0.5.0-py3-none-win_amd64.whl
Size 757.2 kB
Tags Python 3 Windows x86-64
SHA-256 checksum
How to use checksums
7a0637e3d43b51bcbe98d5d57d2a290ea6148413c5a0ab36bf39139184b6f159
BLAKE2b-256 checksum
How to use checksums
e7388d35ad5db7dd7194c65457c332ba7fcfd08020bcd97c12cfeb3abeb88cdf
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 2, 2026.

Transparency log

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

Download URL small_python-0.5.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
8d08c86e411ad82c5dda9825f0a5efae98cbdc0464b9b0fa1d55b86c5ae3b4b6
BLAKE2b-256 checksum
How to use checksums
174a9110b6fd2734ef692eb33802a4c6efe44c18c2ac6da5f86466c40f16a17b
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 2, 2026.

Transparency log

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

Download URL small_python-0.5.0-py3-none-musllinux_1_2_aarch64.whl
Size 2.0 MB
Tags Linux musl 1.2+ ARM64 Python 3
SHA-256 checksum
How to use checksums
6bb44e74f9fb09fef98384d96875a5dd215a624051ddd35af10a68e7121e55c4
BLAKE2b-256 checksum
How to use checksums
ec8d3389afe8f0c6532a1f1afb5e39bf8efcc1335a427a55c367f5b65a081a28
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 2, 2026.

Transparency log

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

Download URL small_python-0.5.0-py3-none-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Size 2.0 MB
Tags Linux glibc 2.17+ x86-64 Linux glibc 2.28+ x86-64 Python 3
SHA-256 checksum
How to use checksums
2c7725ad2fb5520953ddb6fd7caeff8519fbb99b68e5620ce5273d4c679d6f13
BLAKE2b-256 checksum
How to use checksums
9c588d211f439218a50db7f78efb5fd0373856bee153757808c332b15c2b3a66
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 2, 2026.

Transparency log

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

Download URL small_python-0.5.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
5b36521a406c07d0947853d74b2c8034c202141debe54dc2e6c3971d36bddd04
BLAKE2b-256 checksum
How to use checksums
39d5fd7705b2a8ad36be0418cdb5a979d4ff602b36b01337681981a5b713930d
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 2, 2026.

Transparency log

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

Download URL small_python-0.5.0-py3-none-macosx_11_0_arm64.whl
Size 739.6 kB
Tags Python 3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
204ed74eddd392e5eeca8024272e87c008b1ae71bfb0c7c500d81a13d7c16e9f
BLAKE2b-256 checksum
How to use checksums
2a0840035467c9a1795706670563246e3fc5be128b9c7661fc27421097234836
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 2, 2026.

Transparency log

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

Download URL small_python-0.5.0-py3-none-macosx_10_13_x86_64.whl
Size 788.3 kB
Tags Python 3 macOS 10.13+ x86-64
SHA-256 checksum
How to use checksums
cd1573765c4bf8d3fb5afd110f1891ecca53daf53c6cae162e5762f4fea0ea88
BLAKE2b-256 checksum
How to use checksums
4be5a5a5f142203da3d1e0247eb78a84e5c59cabadea220663309bcfac5d823e
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 2, 2026.

Transparency log

Security for small-python 0.5.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.5.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 2, 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