Performance opportunity: support `__vectorcalloffset__` for `__call__`
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 16.2k
- Forks
- 1k
- Avg merge
- 2d 6h
- Merged PRs (30d)
- 66
Description
At the moment our implementation in #[pymethods] of the __call__ member sets the tp_call slot which receives the arguments as a tuple and dictionary.
As an optimization we could instead set __vectorcalloffset__ to direct Python to use the vectorcall protocol for tp_call. I think this probably is supported on Python 3.9 and up.
See the CPython reference - https://docs.python.org/3.9/c-api/typeobj.html#c.PyTypeObject.tp_vectorcall_offset
This would be a fair bit of fiddling around in our macro code and probably also in the create_type_object implementation, however the speedup might be nice! 😄
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 with the #[pymethods] implementation of call and the create_type_object implementation, then consult the CPython tp_vectorcall_offset reference linked in the issue. Trace how tp_call currently receives arguments and determine the macro and type-object changes needed for the vectorcall protocol on Python 3.9 and newer. Done means call uses the vectorcall path without the current tuple and dictionary argument handling.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python, rust
- Domain
- backend-api-design, performance
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100