Pyston (JIT for Python)
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
- breaking Ubuntu 16.04 support was removed in Pyston 2.3.2 due to a dependency dropping support. Users relying on the full Pyston distribution on this OS version must upgrade their operating system or use an older Pyston release.
- gotcha The primary way to enable the Pyston JIT for an existing Python environment via pip is to install `pyston_lite_autoload`. Attempting to install the `pyston` package via `pip` does not enable the JIT; `pyston` typically refers to the standalone Python distribution, installed via other means (e.g., .deb packages, portable archives).
- gotcha Older portable releases of Pyston (e.g., v2.3_portable-v2) contained important bugs (e.g., related to issues #41 and #76) that were fixed in subsequent portable updates (e.g., v2.3_portable-v3). Users of portable distributions should ensure they have the latest patch version for stability.
- gotcha Pyston versions prior to 2.3.2 might experience `setuptools` incompatibilities during package building or installation. A workaround was introduced in version 2.3.2.
- gotcha Pyston-full (the complete distribution) is API-compatible but not ABI-compatible with CPython. This means C extensions generally need to be recompiled when installing packages, which can sometimes lead to issues if binary wheels are not available for Pyston or if necessary build tools (like Rust compiler) are missing.
Install
-
pip install pyston_lite_autoload
Imports
- pyston_lite_autoload
import pyston_lite_autoload
Quickstart
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.