Pyston (JIT for Python)

2.3.5 · active · verified Wed Apr 15

Pyston is a high-performance JIT (Just-In-Time) compiler for Python, designed to significantly speed up Python applications by dynamically optimizing code at runtime. Currently at version 2.3.5, it provides performance improvements and aims for high compatibility with CPython. Its `pyston_lite` extension module offers an easy way to integrate the JIT into existing Python environments, receiving regular updates and enhancements.

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to enable the Pyston JIT by simply importing `pyston_lite_autoload`. Once imported, the JIT automatically optimizes suitable Python code during execution, potentially leading to performance improvements without requiring any further code changes. For optimal observation, run a computationally intensive function.

import pyston_lite_autoload
import time

def fibonacci(n):
    if n <= 1:
        return n
    else:
        return fibonacci(n-1) + fibonacci(n-2)

if __name__ == "__main__":
    print("Pyston JIT enabled by 'pyston_lite_autoload' import.")
    n_val = 35 # A value that takes noticeable time to compute

    start_time = time.perf_counter()
    result = fibonacci(n_val)
    end_time = time.perf_counter()

    print(f"Fibonacci({n_val}) = {result}")
    print(f"Time taken: {end_time - start_time:.4f} seconds")

    # For benchmarking, run this script with and without the 'import pyston_lite_autoload'
    # to observe potential performance differences.

view raw JSON →