Skip to main content

Python bindings for the Ouros sandboxed Python interpreter

Project description

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ouros-0.0.7.tar.gz (2.0 MB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

ouros-0.0.7-cp313-cp313-win_amd64.whl (14.9 MB view details)

Uploaded CPython 3.13Windows x86-64

ouros-0.0.7-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (13.9 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ x86-64

ouros-0.0.7-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (12.8 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ ARM64

ouros-0.0.7-cp313-cp313-macosx_11_0_arm64.whl (12.6 MB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

ouros-0.0.7-cp313-cp313-macosx_10_12_x86_64.whl (13.6 MB view details)

Uploaded CPython 3.13macOS 10.12+ x86-64

ouros-0.0.7-cp312-cp312-win_amd64.whl (14.9 MB view details)

Uploaded CPython 3.12Windows x86-64

ouros-0.0.7-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (13.9 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

ouros-0.0.7-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (12.8 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ ARM64

ouros-0.0.7-cp312-cp312-macosx_11_0_arm64.whl (12.6 MB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

ouros-0.0.7-cp312-cp312-macosx_10_12_x86_64.whl (13.6 MB view details)

Uploaded CPython 3.12macOS 10.12+ x86-64

ouros-0.0.7-cp311-cp311-win_amd64.whl (14.9 MB view details)

Uploaded CPython 3.11Windows x86-64

ouros-0.0.7-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (13.9 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64

ouros-0.0.7-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (12.8 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ ARM64

ouros-0.0.7-cp311-cp311-macosx_11_0_arm64.whl (12.6 MB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

ouros-0.0.7-cp311-cp311-macosx_10_12_x86_64.whl (13.6 MB view details)

Uploaded CPython 3.11macOS 10.12+ x86-64

ouros-0.0.7-cp310-cp310-win_amd64.whl (14.9 MB view details)

Uploaded CPython 3.10Windows x86-64

ouros-0.0.7-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (13.9 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64

ouros-0.0.7-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (12.8 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ ARM64

ouros-0.0.7-cp310-cp310-macosx_11_0_arm64.whl (12.6 MB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

ouros-0.0.7-cp310-cp310-macosx_10_12_x86_64.whl (13.6 MB view details)

Uploaded CPython 3.10macOS 10.12+ x86-64

File details

Details for the file ouros-0.0.7.tar.gz.

File metadata

  • Download URL: ouros-0.0.7.tar.gz
  • Upload date:
  • Size: 2.0 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for ouros-0.0.7.tar.gz
Algorithm Hash digest
SHA256 590fac84ff2d96f022c715d0865b5b362692275374d2ef6df5acd0b607fe8b51
MD5 a77ead8cadb17183bbcd0badc22aa14f
BLAKE2b-256 b7a1208471ba9a0d5e7634525bbc6984b420f1430c9bf4ac9ca993217fad65ee

See more details on using hashes here.

File details

Details for the file ouros-0.0.7-cp313-cp313-win_amd64.whl.

File metadata

  • Download URL: ouros-0.0.7-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 14.9 MB
  • Tags: CPython 3.13, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for ouros-0.0.7-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 86ecb74b1bc7561109fb695851ff46703b9970b8ccec9a17e8a397b860e36c3b
MD5 5b3403a7122dbab6eb3da47dfd5ab975
BLAKE2b-256 6b410e0b78d5fb78fd77be8d47fa70e474863752b10bb20609ad08ccb1cc3799

See more details on using hashes here.

File details

Details for the file ouros-0.0.7-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for ouros-0.0.7-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 c5814cd26453adb296159d4b88c37abf0c24c6f5254d73543b60309ba92a8cd0
MD5 4539d0d581c954de9acb1692fda681a7
BLAKE2b-256 03acafc920e7dd2b1a48b4f9a442e431540de339e5db624c09dc5758fc2cad00

See more details on using hashes here.

File details

Details for the file ouros-0.0.7-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for ouros-0.0.7-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 b713a2e491b048399eec99d9c01d9994a1e613641f9f6195685d774f74735633
MD5 bc17049782c10637bd34c651e4842357
BLAKE2b-256 5291af9b3cf48fe371d8d1368efc2aac9913d6b91ad11322d90d593d90f0d56d

See more details on using hashes here.

File details

Details for the file ouros-0.0.7-cp313-cp313-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for ouros-0.0.7-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 aef0ea89affcd591ae6299f07f2a8030dba5e5d3dfb50cbd6dabf1094576e15f
MD5 782b016bfaff337effbeb4aaea8c22d1
BLAKE2b-256 81bba333f4f60013e1432fb7326b8388474f988e89cf2907fe934d5779e5d285

See more details on using hashes here.

File details

Details for the file ouros-0.0.7-cp313-cp313-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for ouros-0.0.7-cp313-cp313-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 4cdb8572da5048725a36d6661608e87caff45d1036fe4648e04e88b65f94c65d
MD5 85969e39b462bed149d2791ed3b9f714
BLAKE2b-256 4917950050fc3226ec957a5e7f3183dfc64cbbbda92823fbedf01dbf677c888e

See more details on using hashes here.

File details

Details for the file ouros-0.0.7-cp312-cp312-win_amd64.whl.

File metadata

  • Download URL: ouros-0.0.7-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 14.9 MB
  • Tags: CPython 3.12, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for ouros-0.0.7-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 9c2b692fc2878e6b97f6831a48b9ec8f89258053f8fa03d1f4db68a31109ca0e
MD5 430080d8a2aeccf62cd27946f2bc3fc1
BLAKE2b-256 be6dc916b881f4ce510229f8bc656b371d7d0415888084e504ca5b2e276c5a51

See more details on using hashes here.

File details

Details for the file ouros-0.0.7-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for ouros-0.0.7-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 ba07f5e8469fdb97f05543f740dc2f4f7a9dd0a545927d2b1825ac29903150ef
MD5 aaeb1dacb9a344e980ba032d3143558e
BLAKE2b-256 ff6b74786c06a6489882f5c8fae883d9baf8725e0d26dad12f10b525549f3e1b

See more details on using hashes here.

File details

Details for the file ouros-0.0.7-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for ouros-0.0.7-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 a9cc93836e7e682ddd35a56f7356d17adc1f8b849d7459732c19b95fe7b26278
MD5 64e994c07fc00c81667c536e416d9d17
BLAKE2b-256 96ec14abb2d442e7149599bd38ac4b0987fc4d063909aebec129f73f6fbb8b1d

See more details on using hashes here.

File details

Details for the file ouros-0.0.7-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for ouros-0.0.7-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 6a02faafb2ddd81431b304e0beaac4cae2e266fcbb76342a1bdba28de2256218
MD5 ed2ee9fd4c39207d915ad76008a58631
BLAKE2b-256 9f4fb6cd8043afcd84946b9ed34ec1363bcad825ea4132fd5b088f7af961f0b1

See more details on using hashes here.

File details

Details for the file ouros-0.0.7-cp312-cp312-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for ouros-0.0.7-cp312-cp312-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 483d8ed7ef61289f6cc9809943f4a106c40d5bb719ff80ffaac140635fab9003
MD5 c0e2ac91a7913f55b8a7ddb38ec3ca3e
BLAKE2b-256 95339b0b1cd1eb9e8ca273533b96544170c84c0916137e2ebd4556f7c761aeaf

See more details on using hashes here.

File details

Details for the file ouros-0.0.7-cp311-cp311-win_amd64.whl.

File metadata

  • Download URL: ouros-0.0.7-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 14.9 MB
  • Tags: CPython 3.11, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for ouros-0.0.7-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 90b88d1d090decf6a2aa028fe00f299b6efabe960a210cac5160f0e36528d6ab
MD5 3cd81fec0df72f3179a864bfe1315044
BLAKE2b-256 95d9b45979419150155259aaa1ef8412de346dfcd8e5c0b487ef85a7e095d01e

See more details on using hashes here.

File details

Details for the file ouros-0.0.7-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for ouros-0.0.7-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 90b294f7718172ca816ccf779d6ee4b81b3bc87dfa176f070a4ac51f67709e60
MD5 a05d70fb896df9c6a71dffc99e310dc3
BLAKE2b-256 a6142e9b04d3690c10fc10d221c22e2f4e80adfd926f7ce785d45f359b3a1d41

See more details on using hashes here.

File details

Details for the file ouros-0.0.7-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for ouros-0.0.7-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 a72889f744bd61b59f6222c386fd1ef319f80e64e5092354307e5635e6d56e68
MD5 9120dbe0b99191f2dc4a1423292a3d65
BLAKE2b-256 d5a029d6a4f9c76abf5a7fdd1ff5fa738c2ada75b6c898edf6cb21301e170160

See more details on using hashes here.

File details

Details for the file ouros-0.0.7-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for ouros-0.0.7-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 e1776dc1c0faa16498e8a3fc492a9f1e9bec4c42bcd8d540ecafca9852595d66
MD5 fd1c5baf41253c0b7d787311051c922f
BLAKE2b-256 b9a55a739037f2e57a4441fde43bffd649e5c1546d89d9c345ddb91a7ffaac68

See more details on using hashes here.

File details

Details for the file ouros-0.0.7-cp311-cp311-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for ouros-0.0.7-cp311-cp311-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 5966380d0b282f9cfac3ee4975d147a3307b5cd89c660223d8a340701ed372e9
MD5 528336ebf33c8ea6ed88c84817d63196
BLAKE2b-256 e02a6c402755e0ed9c60762c293278edfd738d265596678a2a867d548f2b0220

See more details on using hashes here.

File details

Details for the file ouros-0.0.7-cp310-cp310-win_amd64.whl.

File metadata

  • Download URL: ouros-0.0.7-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 14.9 MB
  • Tags: CPython 3.10, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for ouros-0.0.7-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 9aabdab43ab1d3471dfc48c7ba3f2dc5172a2b9f6415393e776a1f610e1d6694
MD5 f63f3077cb7fe046f2065260d8336aa2
BLAKE2b-256 9a1b99f54e33049ae83af4859ec1e649132b7c824db89b7fc1cf21ce851f47e6

See more details on using hashes here.

File details

Details for the file ouros-0.0.7-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for ouros-0.0.7-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 49daccb5063e5b301e48f84259e82ed5416afc7a75e6743a0b80eb96be151a13
MD5 6f2a2718473056c8b196890bb8a01a39
BLAKE2b-256 6bb417e00569e1efb334c3b0171e11793c08b208b018108266f10e34b991c68e

See more details on using hashes here.

File details

Details for the file ouros-0.0.7-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for ouros-0.0.7-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 38d69430842fe9e7cc76be7a59055fc185823e06bffb773f716fc222a2f7136c
MD5 d7c1845260b7811adccda212e1ec9696
BLAKE2b-256 7360ceaf2b3f24152dcafeb34181c5d05548505104d42986eb53ff9bcd3a7d2e

See more details on using hashes here.

File details

Details for the file ouros-0.0.7-cp310-cp310-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for ouros-0.0.7-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 d4a94b25cf6c6fb5aa9e72d9efbb413d1ce5cc05921adc46e69ffb542e1036dc
MD5 13d1729386584716692ba1a62284bfe8
BLAKE2b-256 97eea48c92f34723b074eb3cd16cfc4d92700686c8c0973666e0f4ecd382db91

See more details on using hashes here.

File details

Details for the file ouros-0.0.7-cp310-cp310-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for ouros-0.0.7-cp310-cp310-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 dc1ca029454a33fec62fb780b3a7cf759ea97023069c057525fdf30514743a8e
MD5 d980070a20958b69e1b81e8290b7b53a
BLAKE2b-256 5be7d48b4d3359264f46bdde74024844ef1b1e5d0521426cace5f25dca3257b6

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page