Function supports compiling a tiny-but-growing subset of Python language constructs. Below are requirements and guidelines for compiling a Python function with Function:

Function Signature

The prediction function must be a module-level function, and must have parameter and return type annotations:

from fxn import compile

@compile(...)
def greeting (name: str) -> str:
    return f"Hello {name}"

The prediction function must not have any variable-length positional or keyword arguments.

Function supports a fixed set of predictor input and output value types. Below are supported type annotations:

Function Body

The function body can contain arbitrary Python code. Given that the Function compiler is currently a proof of concept, it has highly limited coverage. We measure our compiler’s coverage across two dimensions:

Language Coverage

Because Function is designed to cover the full Python language, we keep a list of Python language features that we currently do not support, or only partially support:

Over time the list of unsupported language features will shrink and eventually, will be empty.

Library Coverage

While supporting all Python libraries in the wild is wildly untractable, Function is focused specifically on compute-intensive prediction functions. As such, we mainly plan coverage for a handful of tensor and scientific computing libraries:

If you need a specific library to be supported by the Function compiler, reach out to us.

Try it Out

We currently don’t have a definitive list of what’s supported and what’s not, so the best way to know is to simply try it out πŸ˜‰