jsrun
Modern JavaScript runtime for Python
jsrun is a Python library that embeds the V8 JavaScript engine, allowing you to run JavaScript code directly from Python.
Whether you need to run user scripts, integrate JavaScript libraries, execute code for AI agents, or build extensible Python applications, jsrun provides a robust solution.
Highlights
- ๐ Fast: Powered by V8, the JavaScript engine used in Chrome and Node.js
- ๐ Extensible: Bind Python functions and objects to JavaScript
- โก Async First: Support JavaScript Promises and async function in Python asyncio
- ๐ Isolated Sandbox: Runtime is a V8 isolate that has no I/O access by default
- ๐๏ธ Resource Controls: Prevent abuse by setting per-runtime heap memory limits and execution timeouts
- ๐งต Parallelism: Run multiple runtimes in parallel on different Python threads
- ๐ฆ Module Support: ES modules with custom loaders and resolvers
- โ๏ธ WebAssembly: Execute WebAssembly (WASM) directly in native runtime
- ๐ฏ Typing: Comprehensive type hints for PyO3 bindings
Quick Example
import jsrun
result = jsrun.eval("2 + 2")
print(result) # 4
# Bind Python function
jsrun.bind_function("add", lambda a, b: a + b)
print(jsrun.eval("add(2, 3)")) # 5
Next Steps
- Quick Start - Get up and running with essential features
- Core Concepts - Understand the runtime architecture and execution model
- Type Conversion - Learn how data types map between Python and JavaScript
- Use Cases - Explore practical examples and real-world applications
- API Reference - Comprehensive API documentation for all classes and functions