Skip to content

Discussion: Should functions in lowpp layer be def rather than cpdef? #2766

Description

@mdboom

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?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    triageNeeds the team's attention

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions