[PERF] Construction of known `cdef classes` can go through `__new__`
Nobody has claimed this yet.
- Dominant language
- Cython
- Stars
- 3.4k
- Forks
- 329
- Avg merge
- 1d 23h
- Merged PRs (30d)
- 116
Description
In driver, runtime and nvrtc, when an instance of a cdef class is contructed (usually as a return value), it just uses the obvious Python-level constructor, for example:
cdef CUtensorMap tensorMap = CUtensorMap()
This makes a slow Python-like call (the ironically named PyObject_FastCall).
Instead, following Cythons fast instantiation advice, we can use __new__, which will make a faster C-level call to __cinit__.
cdef CUtensorMap tensorMap = CUtensorMap.__new__(CUtensorMap)
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
Search the driver, runtime, and nvrtc code for constructions of known cdef classes that use the Python-level constructor. Compare those sites with Cython's fast-instantiation guidance and update the applicable construction paths to use new; done means the relevant constructions consistently take the faster C-level path.
Written by the indexing model from the issue text.
Assessment
- Domain
- performance
- Issue type
- Refactor
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100