f2py-jit
==================
[](https://pypi.python.org/pypi/f2py-jit/)
[](https://pypi.python.org/pypi/f2py-jit/)
[](https://en.wikipedia.org/wiki/GNU_General_Public_License)
[](https://mybinder.org/v2/git/https%3A%2F%2Fframagit.org%2Fcoslo%2Ff2py-jit/HEAD?labpath=docs%2Findex.ipynb)
[](https://framagit.org/coslo/f2py-jit/-/commits/master)
[](https://framagit.org/coslo/f2py-jit/-/commits/master)
Just-in-time compilation of Fortran code in Python via [f2py](https://numpy.org/doc/stable/f2py/).
Check out the [documentation](https://coslo.frama.io/f2py-jit/) for full details.
Quick start
-----------
Start from a piece of Fortran `code.f90`
```fortran
subroutine hello()
print*, "Hello world!"
end subroutine
```
Compile the code, import it and execute it
```python
from f2py_jit import jit
f90 = jit('code.f90')
f90.hello()
```
Do the same but from a python string containing the source block
```python
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](https://coslo.frama.io/f2py-jit/tutorial/#performance) [**This feature is experimental**]
```python
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
- f90wrap
- Fortran compiler
Installation
------------
From pip
```
pip install f2py-jit
```
From source
```
git clone https://framagit.org/coslo/f2py-jit.git
cd f2py_jit
make 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/
Raw data
{
"_id": null,
"home_page": "https://framagit.org/coslo/f2py-jit",
"name": "f2py-jit",
"maintainer": "",
"docs_url": null,
"requires_python": "",
"maintainer_email": "",
"keywords": "",
"author": "Daniele Coslovich",
"author_email": "daniele.coslovich@umontpellier.fr",
"download_url": "",
"platform": null,
"description": "f2py-jit\n==================\n\n[](https://pypi.python.org/pypi/f2py-jit/)\n[](https://pypi.python.org/pypi/f2py-jit/)\n[](https://en.wikipedia.org/wiki/GNU_General_Public_License)\n[](https://mybinder.org/v2/git/https%3A%2F%2Fframagit.org%2Fcoslo%2Ff2py-jit/HEAD?labpath=docs%2Findex.ipynb)\n[](https://framagit.org/coslo/f2py-jit/-/commits/master)\n[](https://framagit.org/coslo/f2py-jit/-/commits/master)\n\nJust-in-time compilation of Fortran code in Python via [f2py](https://numpy.org/doc/stable/f2py/).\n\nCheck out the [documentation](https://coslo.frama.io/f2py-jit/) for full details.\n\nQuick start\n-----------\n\nStart from a piece of Fortran `code.f90`\n```fortran\nsubroutine hello()\n print*, \"Hello world!\"\nend subroutine\n```\n\nCompile the code, import it and execute it\n```python\nfrom f2py_jit import jit\nf90 = jit('code.f90')\nf90.hello()\n```\n\nDo the same but from a python string containing the source block\n```python\nsource = \"\"\"\nsubroutine hello()\n print*, \"Hello world!\"\nend subroutine\n\"\"\"\nf90 = jit(source)\nf90.hello()\n```\n\nIf 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](https://coslo.frama.io/f2py-jit/tutorial/#performance) [**This feature is experimental**]\n```python\nf90 = jit('code.f90', inline=True)\n```\n\nFeatures\n--------\n- Compilation of Fortran source blocks as Python strings\n- Caching of module builds across executions\n- Support for Fortran derived types via f90wrap\n- Inlining to improve performance (experimental)\n\nDependencies\n------------\n- numpy\n- f90wrap\n- Fortran compiler\n\nInstallation\n------------\nFrom pip\n```\npip install f2py-jit\n```\n\nFrom source\n```\ngit clone https://framagit.org/coslo/f2py-jit.git\ncd f2py_jit\nmake install\n```\n\nCredits\n-------\nPart of this code is adapted from `numpy.f2py` module by Pearu Peterson, in accordance with the NumPy license.\n\nAuthors\n-------\nDaniele Coslovich: https://www.units.it/daniele.coslovich/\n\n\n",
"bugtrack_url": null,
"license": "GPLv3",
"summary": "Just-in-time Fortran extension builder for Python",
"version": "0.9.2",
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "37e639a83a1bf860e83ae1cd6599648940f47a3fe011fa56af9c195bad683a9c",
"md5": "d300db4501d64afbe0a0d279e456acdf",
"sha256": "41ba35f0b271b9104466510f6bdf8e18da59ef4dfa1b28205b0838956f0a0d0a"
},
"downloads": -1,
"filename": "f2py_jit-0.9.2-py2.py3-none-any.whl",
"has_sig": false,
"md5_digest": "d300db4501d64afbe0a0d279e456acdf",
"packagetype": "bdist_wheel",
"python_version": "py2.py3",
"requires_python": null,
"size": 23530,
"upload_time": "2023-04-15T18:50:31",
"upload_time_iso_8601": "2023-04-15T18:50:31.639328Z",
"url": "https://files.pythonhosted.org/packages/37/e6/39a83a1bf860e83ae1cd6599648940f47a3fe011fa56af9c195bad683a9c/f2py_jit-0.9.2-py2.py3-none-any.whl",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-04-15 18:50:31",
"github": false,
"gitlab": false,
"bitbucket": false,
"lcname": "f2py-jit"
}