LinuxCommandLibrary
GitHubF-DroidGoogle Play Store

pypy

JIT-compiled Python interpreter for speed

TLDR

Run Python script
$ pypy [script.py]
copy
Start interactive mode
$ pypy
copy
Run with arguments
$ pypy [script.py] [arg1] [arg2]
copy
Execute code inline
$ pypy -c "[print('Hello')]"
copy
Run a module as a script
$ pypy -m [module_name]
copy
Install a package using pip through PyPy
$ pypy -m pip install [package]
copy
Run a script with optimizations enabled (removes assert statements)
$ pypy -O [script.py]
copy
Enter interactive mode after running a script (for debugging)
$ pypy -i [script.py]
copy

SYNOPSIS

pypy [options] [script] [args]

DESCRIPTION

PyPy is an alternative Python interpreter that uses a Just-In-Time (JIT) compiler to achieve significantly faster execution than CPython for many workloads. It is compatible with Python 2.7 and Python 3.x syntax and can run most pure-Python code without modification, offering speedups of 2-10x or more on long-running programs.The JIT compiler analyzes code at runtime and compiles frequently executed paths to machine code, so programs that loop heavily or perform repetitive computations benefit the most. PyPy also includes optimizations for memory usage through more compact object representations. Some C extension modules may not be compatible, though cffi-based extensions work well.

PARAMETERS

SCRIPT

Python script to run.
ARGS
Script arguments.
-c CODE
Execute code.
-m MODULE
Run module.
-i
Interactive after script.
-O
Optimize mode: removes assert statements and sets _debug_ to False.
-V, --version
Print the PyPy version and exit.
-u
Unbuffered binary stdout and stderr.
-W arg
Warning control (e.g., -Wall to show all warnings).

CAVEATS

Not all C extension packages are compatible; cffi-based extensions work well but some CPython C API extensions may not. JIT compilation has a warmup period, so short-lived scripts may not see speed improvements. Use pypy -m pip instead of system pip to install packages into the PyPy environment.

HISTORY

PyPy was created as a high-performance Python interpreter with JIT.

SEE ALSO

python(1), python3(1), pip(1)

Copied to clipboard
Kai