Registry / data / pythran

pythran

JSON →
library0.19.0pypypi✓ verified 25d ago

Pythran is an Ahead-of-Time (AOT) compiler that translates a subset of Python, primarily focused on scientific computing and numerical kernels, into native C++14 modules. It aims to provide C++/Fortran-like performance for Python code, leveraging multi-cores and SIMD instructions. The current stable version is 0.18.1, and it actively maintains a release cadence of several updates per year, supporting Python 3.7 and upward.

pip install pythran
INSTALL
IMPORT
SIG · PYTHRAN
P
pythran
datapythonv0.19.0
Install
5.3s avg
Import
2203ms
Disk
132MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.19.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 2.282s · 128.4MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 5.3s · import 2.124s · 125MB
132MB installed
● package 132MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

PythranExtension
from pythran import PythranExtension
import compiled_module
compile_pythrancode
from pythran import compile_pythrancode
compile_pythranfile
from pythran import compile_pythranfile

Create a Python file with numerical kernels annotated for export. Compile it using the `pythran` command-line tool, then import the resulting native module. This example defines a dot product function.

# dprod.py """ Naive dotproduct! Pythran supports numpy.dot """ #pythran export dprod(int list, int list) def dprod(l0, l1): """WoW, generator expression, zip and sum.""" return sum(x * y for x, y in zip(l0, l1)) # To compile the Python file to a native module: # pythran dprod.py # Then, import and use the compiled module: # python -c 'import dprod; print(dprod.dprod([1,2,3], [4,5,6]))'
pythran --version
Debug
Known issues
breakingPythran dropped support for Python 2.7 after version 0.9.5. It now exclusively supports Python 3.7 and upward.
fix
Ensure your project uses Python 3.7 or newer.
affects: <=0.9.5 (Python 2.7 support), >0.9.5 (Python 3.7+ only)
gotchaPythran only supports a subset of the Python language, specifically targeting numerical computing. Features like classes, polymorphic variables (with some exceptions), and heterogeneous containers (except tuples) are not supported.
fix
Design your functions to adhere to Pythran's supported Python subset, typically pure numerical functions operating on primitive types and NumPy arrays.
affects: All versions
gotchaA C++14 enabled compiler (e.g., g++ >= 5, clang >= 3.5) is a prerequisite for Pythran. Older compilers may lead to compilation errors.
fix
Update your system's C++ compiler to a version that supports C++14 standards.
affects: All versions
gotchaFor optimal performance, users often need to explicitly specify compiler optimization flags (e.g., `-O3`, `-fopenmp`, `-march=native`) either via the `pythran` CLI or in a `~/.pythranrc` configuration file.
fix
Consult Pythran's documentation for recommended optimization flags and consider setting them in `~/.pythranrc` or passing them directly to the `pythran` command.
affects: All versions
deprecatedSupport for `numpy.distutils` with Python 3.9 was obsoleted in Pythran 0.18.0. Users integrating Pythran into larger build systems might need to adapt.
fix
Migrate build systems away from `numpy.distutils` if targeting Python 3.9+ with Pythran 0.18.0+.
affects: 0.18.0 and later
gotchaWindows support for Pythran is ongoing and primarily targets Visual Studio 2017 or clang-cl. Specific environment variables (`CXX`, `CC`) might be required for proper setup.
fix
Refer to the Pythran documentation for detailed Windows installation and configuration instructions, especially regarding compiler setup.
affects: All versions on Windows
Upgrade
Version history
0.19.0latest on PyPI · released Aug 17, 2026
Audit
Dependencies
plyrequiredLex & Yacc parsing, required for Pythran's AST processing.
setuptoolsrequiredUsed for building and distributing Pythran extensions, especially via PythranExtension.
gastrequiredPython AST that abstracts the underlying Python version, used in AST transformations.
numpyrequiredCore dependency for numerical operations and array support.
benigetrequiredExtracts semantic information about static Python code, used in Pythran's analysis passes.
boostoptionalC++ library dependency, often vendored in PyPI packages but may be external for other distributions.
xsimdoptionalC++ library for SIMD vectorization, often vendored in PyPI packages.
C++14 enabled compiler (e.g., g++>=5, clang>=3.5)requiredRequired to compile the generated C++ code.
Agent activity
12 hits · last 30 days
node
10
OpenAI (training)
1
Resources
pythran — pip install pythran · libregistry