Functions in the lowpp layer are currently declared with cpdef, so they are exposed to both Cython and Python. However, we have always claimed that the Cython interface is not stable, and shouldn't be relied on.
A couple discoveries today are making me wonder whether we want to keep exposing the lowpp layer to Cython at all:
- Calling a
cpdef function from Python has an additional 50ns of overhead vs. a def function (the Python layer delegates to an underlying layer and there is additional work done at that boundary).
cpdef functions can not have their return type annotated, which is a blocker for proper .pyi support for the lowpp layer.
Is Cython access at the lowpp layer providing any value here? Could we just s/cpdef/def/g and get more performance and a more Pythonic experience?
Functions in the
lowpplayer are currently declared withcpdef, so they are exposed to both Cython and Python. However, we have always claimed that theCythoninterface is not stable, and shouldn't be relied on.A couple discoveries today are making me wonder whether we want to keep exposing the
lowpplayer to Cython at all:cpdeffunction from Python has an additional 50ns of overhead vs. adeffunction (the Python layer delegates to an underlying layer and there is additional work done at that boundary).cpdeffunctions can not have their return type annotated, which is a blocker for proper.pyisupport for the lowpp layer.Is Cython access at the lowpp layer providing any value here? Could we just
s/cpdef/def/gand get more performance and a more Pythonic experience?