Skip to main content

jitto 🚀

jitto is a lightweight, zero-dependency Universal Just-In-Time (JIT) Compilation Engine for Python language creators, interpreters, and compilers.

It was created to power custom programming languages—such as new_eval—by ingesting their AST nodes and compiling them directly into native ARM64 (Apple Silicon) and 64-bit x86 (Intel/AMD) machine code for hardware-speed execution.


Key Features

  • Universal AST Agnostic: Ingests AST nodes from custom language parsers (like new_eval) without requiring custom glue code.
  • Multi-Architecture Support: Automatically detects and emits native ARM64 (AArch64) or x86-64 machine code instructions.
  • Zero External Dependencies: Uses pure Python built-in modules (mmap, ctypes, struct).
  • Variable Scope Binding: Evaluates expressions with dynamic variable environment dictionaries (variables={"x": 10}).
  • Thread-Safe Memory Allocation: Verified under concurrent multi-threaded JIT compilation workloads.

Installation

pip install jitto

Or for local development:

pip install -e .

Quickstart

1-Liner JIT Execution

import ast
from jitto import run_jit

# Compiles AST directly to native machine code & executes on CPU hardware
result = run_jit(ast.parse("100 - (15 * 4)", mode="eval"))
print("JIT Execution Result:", result)  # Outputs: 40

Universal AST Examples

1. Integration Example: Giving new_eval a Native JIT Compiler

If your custom language (like new_eval) uses @dataclass nodes or custom parser objects:

from dataclasses import dataclass
from jitto import run_jit

# AST nodes from the new_eval language parser
@dataclass
class Int_Node:
    value: int

@dataclass
class BinOps_Node:
    left: any
    ops: str
    right: any

# new_eval AST: 10 + (20 * 3)
new_eval_ast = BinOps_Node(
    left=Int_Node(10),
    ops="+",
    right=BinOps_Node(left=Int_Node(20), ops="*", right=Int_Node(3))
)

# Run new_eval AST natively on hardware CPU!
result = run_jit(new_eval_ast)
print("new_eval JIT Execution Result:", result)  # Outputs: 70

2. JSON / Dictionary AST

from jitto import run_jit

dict_ast = {
    "type": "BinOp",
    "op": "*",
    "left": {
        "type": "BinOp",
        "op": "+",
        "left": {"type": "Constant", "value": 5},
        "right": {"type": "Constant", "value": 15}
    },
    "right": {"type": "Constant", "value": 4}
}

result = run_jit(dict_ast)
print("Dict AST JIT Result:", result)  # Outputs: 80

3. Variable Environment Bindings

import ast
from jitto import run_jit

# Evaluates (a + b) * (c - d) natively on CPU hardware
ast_tree = ast.parse("(a + b) * (c - d)", mode="eval")
variables = {"a": 5, "b": 5, "c": 20, "d": 10}

result = run_jit(ast_tree, variables=variables)
print("Variable JIT Result:", result)  # Outputs: 100

Compiler Architecture

┌──────────────────────────────────────────────────────────────┐
│                    Universal AST Inputs                      │
│                                                              │
│  - Python ast.parse()  - Dataclasses (new_eval)  - Dicts     │
└──────────────────────────────┬───────────────────────────────┘
                               │
                               ▼
┌──────────────────────────────────────────────────────────────┐
│                  Universal AST Normalizer                    │
│                                                              │
│  Standardizes arbitrary AST node fields into internal nodes  │
└──────────────────────────────┬───────────────────────────────┘
                               │
                               ▼
┌──────────────────────────────────────────────────────────────┐
│             3-Address Intermediate Code (IR)                 │
│                                                              │
│  Linearizes AST into LOAD_IMM, ADD, SUB, MUL & Register Alloc│
└──────────────────────────────┬───────────────────────────────┘
                               │
                               ▼
┌──────────────────────────────────────────────────────────────┐
│         Multi-Arch Machine Code Encoder (ARM64 / x86-64)      │
│                                                              │
│  Emits 64-bit CPU binary opcodes (MOVZ, ADD, SUB, MUL, RET)  │
└──────────────────────────────┬───────────────────────────────┘
                               │
                               ▼
┌──────────────────────────────────────────────────────────────┐
│             Native RWX Memory Executor (mmap + ctypes)       │
│                                                              │
│ Executes machine bytes natively on CPU via function pointers │
└──────────────────────────────────────────────────────────────┘

Testing & Stability

jitto passes 5 comprehensive test suites comprising 22 test cases and over 1,600 continuous JIT executions:

  • ARM64 & x86-64 Code Emission: Verified on macOS Apple Silicon, Intel Mac, and Linux.
  • Signed 64-Bit Boundaries: Verified for negative returns (-40) and large integers (6,000,000,000).
  • Multi-Threaded Concurrency: Verified across 10 concurrent threads with 500 parallel compilations.
  • Deep AST Trees: Verified 30-level deep expression trees.

License

MIT

Metadata

Release files for jitto 0.2.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 jitto 0.2.0
File Size Uploaded Provenance Actions
jitto-0.2.0.tar.gz 10.7 kB Without provenance Details for jitto-0.2.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for jitto 0.2.0
File Interpreter ABI Platform Actions
jitto-0.2.0-py3-none-any.whl Python 3 none any Details for jitto-0.2.0-py3-none-any.whl

Total release size: 21.0 kB

Release files / jitto-0.2.0.tar.gz

Download URL jitto-0.2.0.tar.gz
Size 10.7 kB
Tags Source
SHA-256 checksum
How to use checksums
03bef1105a15ecb93f3a454d66b5b3c19dbe8588c8f7f330b294ff812fe70165
BLAKE2b-256 checksum
How to use checksums
41613f7bc69a519612813efca57fc1b0c26dfa094ced250e36161413fdc4d55d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.6

Release files / jitto-0.2.0-py3-none-any.whl

Download URL jitto-0.2.0-py3-none-any.whl
Size 10.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d2a9f8315f319dffb12b7b6234b41601b001948c0d71379bb1beaa6f2f97be56
BLAKE2b-256 checksum
How to use checksums
f17d27f5450810663a8ee310e35ee0ebe216727085ed81b89b1ec9651f2d84e5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.6

Security for jitto 0.2.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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

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.

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 release files No provenance

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