Discussion: Should functions in lowpp layer be `def` rather than `cpdef`?
Nobody has claimed this yet.
- Dominant language
- Cython
- Stars
- 3.4k
- Forks
- 329
- Avg merge
- 1d 23h
- Merged PRs (30d)
- 116
Description
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
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/g and get more performance and a more Pythonic experience?
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by locating the functions in the lowpp layer and reviewing how they are exposed to Cython and Python. Compare the existing cpdef behavior with the stated .pyi and performance constraints, then check the discussion for a decision. Done means the project has agreed whether Cython exposure should remain; the issue does not identify specific files or tests.
Written by the indexing model from the issue text.
Assessment
- Domain
- backend
- Issue type
- Refactor
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Active
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100