miniff issueshttps://gitlab.kwant-project.org/qt/miniff/-/issues2021-01-25T11:31:30Zhttps://gitlab.kwant-project.org/qt/miniff/-/issues/21Baking (compiling) fast efficient functions during runtime2021-01-25T11:31:30ZArtem PulkinBaking (compiling) fast efficient functions during runtimeCurrently, bottleneck "potential" functions are compiled at the build time as a separate `_potentials` library. This may not be the optimal choice for those users who are willing to define their own potentials. Currently, they will have ...Currently, bottleneck "potential" functions are compiled at the build time as a separate `_potentials` library. This may not be the optimal choice for those users who are willing to define their own potentials. Currently, they will have to modify package sources and to re-compile it. Another option is to implement compiling during runtime taking simple potential expressions as the input and producing fast library functions as the output.
Function stub example:
```python
def build_potential(expression: str, inputs: Iterable, type: str, openmp: bool=True) -> Callable:
"""
Builds a potential or its gradient with the given expression.
Args:
expression: numerical formula of the potential in python formatting;
inputs: adjustable parameters of the potential;
type: the type of the potential ('potential-2-g' for example);
openmp: if True, makes a parallel function compiled against OpenMP;
Returns:
A function implementing this potential.
"""
# Assemble sources, compile and import the function
```