FortranCon2021: f2py: Two Decades Later
Channel: FortranCon
Date: 15/11/2021

Speaker: Rohit Goswami
Material: https://tcevents.chem.uzh.ch/event/14/contributions/82/

`f2py` is the gold standard for interfacing Fortran and Python. The most famous downstream consumer of the generated wrappers is undoubtedly the `scipy` ecosystem. Crucially, `f2py` is not a compiler, and generates a best effort set of wrappers, aided by special comment lines. One of the key inter-operable approaches to compilation of the subsequent wrappers relies on `numpy.distutils`. Given the planned obsolescence of this module; we discuss the methology by which the build phase can be splitinto a two phase process and document better the `pyf` enhancements made to facilitate callbacks. A brief outline of test suites and documentation within the `numpy` ecosystem and proposed enhancement proposals will be discussed as well. We lay out the roadmap towards `f2py` remaining relevant beyond `f77` by implementing derived types and newer features like parallelism with co-arrays. Playing to its strengths as a code-enhancer and leveraging the flexibility of not being constrained by the actual compilation process allows for the reimagining of `f2py` as a tool and library.