Skip to main content

f2py-jit

pypi version license Binder pipeline status coverage report

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)
  • numpy
  • meson (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/

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

f2py_jit-1.2.2.tar.gz (29.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

f2py_jit-1.2.2-py3-none-any.whl (26.1 kB view details)

Uploaded Python 3

File details

Details for the file f2py_jit-1.2.2.tar.gz.

File metadata

  • Download URL: f2py_jit-1.2.2.tar.gz
  • Upload date:
  • Size: 29.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.12

File hashes

Hashes for f2py_jit-1.2.2.tar.gz
Algorithm Hash digest
SHA256 078851484137f1d65a7e58deb7be8eecf43a8c9f71f9142eb655d19006df0de2
MD5 46102908de38ab3995d5b6aac8950e11
BLAKE2b-256 6f65025ebbe575496b9748a610e132fe7fb2e78bab7fb05bf355934ecb2514e4

See more details on using hashes here.

File details

Details for the file f2py_jit-1.2.2-py3-none-any.whl.

File metadata

  • Download URL: f2py_jit-1.2.2-py3-none-any.whl
  • Upload date:
  • Size: 26.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.12

File hashes

Hashes for f2py_jit-1.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 7b521250b544bc4f107361b66ef0f0e5ae7ae20e1177b43fe2d1524a28bd638a
MD5 d97d7f30ba97f02ee4e27d723411fa50
BLAKE2b-256 47accafad289134ceff4b340af9985b3afea885dcb60c7d76a59466114e8ebdf

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

1.2.2 This release

2 files

1.2.1

2 files

1.2.0

2 files

1.1.1

2 files

1.1.0

2 files

1.0.1

2 files

1.0.0

2 files

0.11.0

1 file

0.10.3

1 file

0.10.2

1 file

0.10.1

1 file

0.10.0

1 file

0.9.2

1 file

0.9.1

1 file

0.9.0

1 file

0.8.5

1 file

0.8.4

1 file

0.8.3

1 file

0.8.2

1 file

0.8.1

1 file

0.8.0

1 file

0.7.0

1 file

0.6.0

1 file

0.5.0

1 file

0.4.1

1 file

0.3.1

1 file

0.2.1

1 file

0.2.0

1 file

0.1.4

1 file

0.1.3

1 file

0.1.2

1 file

0.1.1

1 file

0.1.0

1 file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page