Just-in-time Fortran extension builder for Python
Project description
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 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
numpy
- Fortran compiler (ex.
gfortran
)
The package currently supports Python versions from 3.7 to 3.13.
Note that Python versions >= 3.12 will use the meson
backend to build Fortran extensions, which has slower build times than distutils
(used by default in versions < 3.12).
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/
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file f2py_jit-1.1.0.tar.gz
.
File metadata
- Download URL: f2py_jit-1.1.0.tar.gz
- Upload date:
- Size: 27.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ac06e6a6183400ec0302aa6bc8a43bc63dbcdf864f915d903965ddb13ea2e4ea |
|
MD5 | 3d9a819347d2f8c6b328be760b49658d |
|
BLAKE2b-256 | 976f4c1f21ec89d55c3268723660a38e5331619d9b5569a247794b8d7a3347e5 |
Provenance
File details
Details for the file f2py_jit-1.1.0-py3-none-any.whl
.
File metadata
- Download URL: f2py_jit-1.1.0-py3-none-any.whl
- Upload date:
- Size: 24.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6e848b404e9f2145472b67b74382e2d6071549729549af5aeae1fc59901d0ff9 |
|
MD5 | 5257b8db04fec0a38580faa876659859 |
|
BLAKE2b-256 | 20f5e83c0b7800e73757fe29e8ece9a4b55e7421a1c87564bfff890873a8fe1b |