ouros
Python bindings for the Ouros sandboxed Python interpreter.
Installation
pip install ouros
Usage
Basic Expression Evaluation
import ouros
# Simple code with no inputs
m = ouros.Sandbox('1 + 2')
print(m.run())
#> 3
Using Input Variables
import ouros
# Create with code that uses input variables
m = ouros.Sandbox('x * y', inputs=['x', 'y'])
# Run multiple times with different inputs
print(m.run(inputs={'x': 2, 'y': 3}))
#> 6
print(m.run(inputs={'x': 10, 'y': 5}))
#> 50
Resource Limits
import ouros
m = ouros.Sandbox('x + y', inputs=['x', 'y'])
# With resource limits
limits = ouros.ResourceLimits(max_duration_secs=1.0)
result = m.run(inputs={'x': 1, 'y': 2}, limits=limits)
assert result == 3
External Functions
import ouros
# Code that calls an external function
m = ouros.Sandbox('double(x)', inputs=['x'], external_functions=['double'])
# Provide the external function implementation at runtime
result = m.run(inputs={'x': 5}, external_functions={'double': lambda x: x * 2})
print(result)
#> 10
Iterative Execution with External Functions
Use start() and resume() to handle external function calls iteratively,
giving you control over each call:
import ouros
code = """
data = fetch(url)
len(data)
"""
m = ouros.Sandbox(code, inputs=['url'], external_functions=['fetch'])
# Start execution - pauses when fetch() is called
result = m.start(inputs={'url': 'https://example.com'})
print(type(result))
#> <class 'ouros.Snapshot'>
print(result.function_name) # fetch
#> fetch
print(result.args)
#> ('https://example.com',)
# Perform the actual fetch, then resume with the result
result = result.resume(return_value='hello world')
print(type(result))
#> <class 'ouros.Complete'>
print(result.output)
#> 11
Serialization
Both Sandbox and Snapshot can be serialized to bytes and restored later.
This allows caching parsed code or suspending execution across process boundaries:
import ouros
# Serialize parsed code to avoid re-parsing
m = ouros.Sandbox('x + 1', inputs=['x'])
data = m.dump()
# Later, restore and run
m2 = ouros.Sandbox.load(data)
print(m2.run(inputs={'x': 41}))
#> 42
Execution state can also be serialized mid-flight:
import ouros
m = ouros.Sandbox('fetch(url)', inputs=['url'], external_functions=['fetch'])
progress = m.start(inputs={'url': 'https://example.com'})
# Serialize the execution state
state = progress.dump()
# Later, restore and resume (e.g., in a different process)
progress2 = ouros.Snapshot.load(state)
result = progress2.resume(return_value='response data')
print(result.output)
#> response data
Metadata
Release files for ouros 0.0.7
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| ouros-0.0.7.tar.gz | 2.0 MB | Details |
Built distributions (wheels)
Total release size: 273.2 MB
Release files / ouros-0.0.7.tar.gz
| Download URL | ouros-0.0.7.tar.gz |
|---|---|
| Size | 2.0 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
590fac84ff2d96f022c715d0865b5b362692275374d2ef6df5acd0b607fe8b51
|
|
BLAKE2b-256 checksum How to use checksums |
b7a1208471ba9a0d5e7634525bbc6984b420f1430c9bf4ac9ca993217fad65ee
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Release files / ouros-0.0.7-cp313-cp313-win_amd64.whl
| Download URL | ouros-0.0.7-cp313-cp313-win_amd64.whl |
|---|---|
| Size | 14.9 MB |
| Tags | CPython 3.13 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
86ecb74b1bc7561109fb695851ff46703b9970b8ccec9a17e8a397b860e36c3b
|
|
BLAKE2b-256 checksum How to use checksums |
6b410e0b78d5fb78fd77be8d47fa70e474863752b10bb20609ad08ccb1cc3799
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Release files / ouros-0.0.7-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | ouros-0.0.7-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 13.9 MB |
| Tags | CPython 3.13 Linux glibc 2.17+ x86-64 |
|
SHA-256 checksum How to use checksums |
c5814cd26453adb296159d4b88c37abf0c24c6f5254d73543b60309ba92a8cd0
|
|
BLAKE2b-256 checksum How to use checksums |
03acafc920e7dd2b1a48b4f9a442e431540de339e5db624c09dc5758fc2cad00
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Release files / ouros-0.0.7-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
| Download URL | ouros-0.0.7-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl |
|---|---|
| Size | 12.8 MB |
| Tags | CPython 3.13 Linux glibc 2.17+ ARM64 |
|
SHA-256 checksum How to use checksums |
b713a2e491b048399eec99d9c01d9994a1e613641f9f6195685d774f74735633
|
|
BLAKE2b-256 checksum How to use checksums |
5291af9b3cf48fe371d8d1368efc2aac9913d6b91ad11322d90d593d90f0d56d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Release files / ouros-0.0.7-cp313-cp313-macosx_11_0_arm64.whl
| Download URL | ouros-0.0.7-cp313-cp313-macosx_11_0_arm64.whl |
|---|---|
| Size | 12.6 MB |
| Tags | CPython 3.13 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
aef0ea89affcd591ae6299f07f2a8030dba5e5d3dfb50cbd6dabf1094576e15f
|
|
BLAKE2b-256 checksum How to use checksums |
81bba333f4f60013e1432fb7326b8388474f988e89cf2907fe934d5779e5d285
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Release files / ouros-0.0.7-cp313-cp313-macosx_10_12_x86_64.whl
| Download URL | ouros-0.0.7-cp313-cp313-macosx_10_12_x86_64.whl |
|---|---|
| Size | 13.6 MB |
| Tags | CPython 3.13 macOS 10.12+ x86-64 |
|
SHA-256 checksum How to use checksums |
4cdb8572da5048725a36d6661608e87caff45d1036fe4648e04e88b65f94c65d
|
|
BLAKE2b-256 checksum How to use checksums |
4917950050fc3226ec957a5e7f3183dfc64cbbbda92823fbedf01dbf677c888e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Release files / ouros-0.0.7-cp312-cp312-win_amd64.whl
| Download URL | ouros-0.0.7-cp312-cp312-win_amd64.whl |
|---|---|
| Size | 14.9 MB |
| Tags | CPython 3.12 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
9c2b692fc2878e6b97f6831a48b9ec8f89258053f8fa03d1f4db68a31109ca0e
|
|
BLAKE2b-256 checksum How to use checksums |
be6dc916b881f4ce510229f8bc656b371d7d0415888084e504ca5b2e276c5a51
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Release files / ouros-0.0.7-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | ouros-0.0.7-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 13.9 MB |
| Tags | CPython 3.12 Linux glibc 2.17+ x86-64 |
|
SHA-256 checksum How to use checksums |
ba07f5e8469fdb97f05543f740dc2f4f7a9dd0a545927d2b1825ac29903150ef
|
|
BLAKE2b-256 checksum How to use checksums |
ff6b74786c06a6489882f5c8fae883d9baf8725e0d26dad12f10b525549f3e1b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Release files / ouros-0.0.7-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
| Download URL | ouros-0.0.7-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl |
|---|---|
| Size | 12.8 MB |
| Tags | CPython 3.12 Linux glibc 2.17+ ARM64 |
|
SHA-256 checksum How to use checksums |
a9cc93836e7e682ddd35a56f7356d17adc1f8b849d7459732c19b95fe7b26278
|
|
BLAKE2b-256 checksum How to use checksums |
96ec14abb2d442e7149599bd38ac4b0987fc4d063909aebec129f73f6fbb8b1d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Release files / ouros-0.0.7-cp312-cp312-macosx_11_0_arm64.whl
| Download URL | ouros-0.0.7-cp312-cp312-macosx_11_0_arm64.whl |
|---|---|
| Size | 12.6 MB |
| Tags | CPython 3.12 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
6a02faafb2ddd81431b304e0beaac4cae2e266fcbb76342a1bdba28de2256218
|
|
BLAKE2b-256 checksum How to use checksums |
9f4fb6cd8043afcd84946b9ed34ec1363bcad825ea4132fd5b088f7af961f0b1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Release files / ouros-0.0.7-cp312-cp312-macosx_10_12_x86_64.whl
| Download URL | ouros-0.0.7-cp312-cp312-macosx_10_12_x86_64.whl |
|---|---|
| Size | 13.6 MB |
| Tags | CPython 3.12 macOS 10.12+ x86-64 |
|
SHA-256 checksum How to use checksums |
483d8ed7ef61289f6cc9809943f4a106c40d5bb719ff80ffaac140635fab9003
|
|
BLAKE2b-256 checksum How to use checksums |
95339b0b1cd1eb9e8ca273533b96544170c84c0916137e2ebd4556f7c761aeaf
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Release files / ouros-0.0.7-cp311-cp311-win_amd64.whl
| Download URL | ouros-0.0.7-cp311-cp311-win_amd64.whl |
|---|---|
| Size | 14.9 MB |
| Tags | CPython 3.11 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
90b88d1d090decf6a2aa028fe00f299b6efabe960a210cac5160f0e36528d6ab
|
|
BLAKE2b-256 checksum How to use checksums |
95d9b45979419150155259aaa1ef8412de346dfcd8e5c0b487ef85a7e095d01e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Release files / ouros-0.0.7-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | ouros-0.0.7-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 13.9 MB |
| Tags | CPython 3.11 Linux glibc 2.17+ x86-64 |
|
SHA-256 checksum How to use checksums |
90b294f7718172ca816ccf779d6ee4b81b3bc87dfa176f070a4ac51f67709e60
|
|
BLAKE2b-256 checksum How to use checksums |
a6142e9b04d3690c10fc10d221c22e2f4e80adfd926f7ce785d45f359b3a1d41
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Release files / ouros-0.0.7-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
| Download URL | ouros-0.0.7-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl |
|---|---|
| Size | 12.8 MB |
| Tags | CPython 3.11 Linux glibc 2.17+ ARM64 |
|
SHA-256 checksum How to use checksums |
a72889f744bd61b59f6222c386fd1ef319f80e64e5092354307e5635e6d56e68
|
|
BLAKE2b-256 checksum How to use checksums |
d5a029d6a4f9c76abf5a7fdd1ff5fa738c2ada75b6c898edf6cb21301e170160
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Release files / ouros-0.0.7-cp311-cp311-macosx_11_0_arm64.whl
| Download URL | ouros-0.0.7-cp311-cp311-macosx_11_0_arm64.whl |
|---|---|
| Size | 12.6 MB |
| Tags | CPython 3.11 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
e1776dc1c0faa16498e8a3fc492a9f1e9bec4c42bcd8d540ecafca9852595d66
|
|
BLAKE2b-256 checksum How to use checksums |
b9a55a739037f2e57a4441fde43bffd649e5c1546d89d9c345ddb91a7ffaac68
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Release files / ouros-0.0.7-cp311-cp311-macosx_10_12_x86_64.whl
| Download URL | ouros-0.0.7-cp311-cp311-macosx_10_12_x86_64.whl |
|---|---|
| Size | 13.6 MB |
| Tags | CPython 3.11 macOS 10.12+ x86-64 |
|
SHA-256 checksum How to use checksums |
5966380d0b282f9cfac3ee4975d147a3307b5cd89c660223d8a340701ed372e9
|
|
BLAKE2b-256 checksum How to use checksums |
e02a6c402755e0ed9c60762c293278edfd738d265596678a2a867d548f2b0220
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Release files / ouros-0.0.7-cp310-cp310-win_amd64.whl
| Download URL | ouros-0.0.7-cp310-cp310-win_amd64.whl |
|---|---|
| Size | 14.9 MB |
| Tags | CPython 3.10 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
9aabdab43ab1d3471dfc48c7ba3f2dc5172a2b9f6415393e776a1f610e1d6694
|
|
BLAKE2b-256 checksum How to use checksums |
9a1b99f54e33049ae83af4859ec1e649132b7c824db89b7fc1cf21ce851f47e6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Release files / ouros-0.0.7-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | ouros-0.0.7-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 13.9 MB |
| Tags | CPython 3.10 Linux glibc 2.17+ x86-64 |
|
SHA-256 checksum How to use checksums |
49daccb5063e5b301e48f84259e82ed5416afc7a75e6743a0b80eb96be151a13
|
|
BLAKE2b-256 checksum How to use checksums |
6bb417e00569e1efb334c3b0171e11793c08b208b018108266f10e34b991c68e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Release files / ouros-0.0.7-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
| Download URL | ouros-0.0.7-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl |
|---|---|
| Size | 12.8 MB |
| Tags | CPython 3.10 Linux glibc 2.17+ ARM64 |
|
SHA-256 checksum How to use checksums |
38d69430842fe9e7cc76be7a59055fc185823e06bffb773f716fc222a2f7136c
|
|
BLAKE2b-256 checksum How to use checksums |
7360ceaf2b3f24152dcafeb34181c5d05548505104d42986eb53ff9bcd3a7d2e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Release files / ouros-0.0.7-cp310-cp310-macosx_11_0_arm64.whl
| Download URL | ouros-0.0.7-cp310-cp310-macosx_11_0_arm64.whl |
|---|---|
| Size | 12.6 MB |
| Tags | CPython 3.10 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
d4a94b25cf6c6fb5aa9e72d9efbb413d1ce5cc05921adc46e69ffb542e1036dc
|
|
BLAKE2b-256 checksum How to use checksums |
97eea48c92f34723b074eb3cd16cfc4d92700686c8c0973666e0f4ecd382db91
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Release files / ouros-0.0.7-cp310-cp310-macosx_10_12_x86_64.whl
| Download URL | ouros-0.0.7-cp310-cp310-macosx_10_12_x86_64.whl |
|---|---|
| Size | 13.6 MB |
| Tags | CPython 3.10 macOS 10.12+ x86-64 |
|
SHA-256 checksum How to use checksums |
dc1ca029454a33fec62fb780b3a7cf759ea97023069c057525fdf30514743a8e
|
|
BLAKE2b-256 checksum How to use checksums |
5be7d48b4d3359264f46bdde74024844ef1b1e5d0521426cace5f25dca3257b6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|