f2py-jit
Just-in-time compilation of Fortran code in Python via f2py.
Check out the documentation for full details.
Quick start
Start from a piece of Fortran, say code.f90
subroutine hello()
print*, "Hello world!"
end subroutine
Compile the code, import it and execute it
from f2py_jit import jit
f90 = jit('code.f90')
f90.hello()
Do the same but from a python string containing the source block
source = """
subroutine hello()
print*, "Hello world!"
end subroutine
"""
f90 = jit(source)
f90.hello()
If the Fortran source contains multiple subroutines calling each other, f2py will not perform interprocedural optimizations (at least not by default). f2py_jit can inline the source code before compiling it, and you will get a performace boost [This feature is experimental]
f90 = jit('code.f90', inline=True)
Features
- Compilation of Fortran source blocks as Python strings
- Caching of module builds across executions
- Support for Fortran derived types via f90wrap
- Inlining to improve performance (experimental)
Dependencies
- Fortran compiler (ex.
gfortran) numpymeson(for Python >= 3.11)
The package currently supports Python versions from 3.7 to 3.14.
Important: on Debian-based OS, packages pkg-config and python3-dev are required with Python>=3.11. They must be installed at the OS level ex. via apt.
Note: Python versions >= 3.11 will use the meson backend to build Fortran extensions, which has slower build times than distutils (used by default in versions < 3.11).
Installation
From pip
pip install f2py-jit
To install the package with support for derived types (courtesy of f90wrap
pip install f2py-jit[types]
Note that this requires Python >= 3.8.
From source
git clone https://framagit.org/coslo/f2py-jit.git
cd f2py_jit
pip install .
Credits
Part of this code is adapted from numpy.f2py module by Pearu Peterson, in accordance with the NumPy license.
Authors
Daniele Coslovich: https://www.units.it/daniele.coslovich/
Metadata
Release files for f2py-jit 1.2.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| f2py_jit-1.2.2.tar.gz | 29.2 kB | Without provenance | Details for f2py_jit-1.2.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| f2py_jit-1.2.2-py3-none-any.whl | Python 3 | none | any | Details for f2py_jit-1.2.2-py3-none-any.whl |
Total release size: 55.3 kB
Release files / f2py_jit-1.2.2.tar.gz
| Download URL | f2py_jit-1.2.2.tar.gz |
|---|---|
| Size | 29.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
078851484137f1d65a7e58deb7be8eecf43a8c9f71f9142eb655d19006df0de2
|
|
BLAKE2b-256 checksum How to use checksums |
6f65025ebbe575496b9748a610e132fe7fb2e78bab7fb05bf355934ecb2514e4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.10.12
|
Release files / f2py_jit-1.2.2-py3-none-any.whl
| Download URL | f2py_jit-1.2.2-py3-none-any.whl |
|---|---|
| Size | 26.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
7b521250b544bc4f107361b66ef0f0e5ae7ae20e1177b43fe2d1524a28bd638a
|
|
BLAKE2b-256 checksum How to use checksums |
47accafad289134ceff4b340af9985b3afea885dcb60c7d76a59466114e8ebdf
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.10.12
|
Security for f2py-jit 1.2.2
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.