You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Use METH_FASTCALL protocol in Python bindings #49476
featureA request for a proper, new feature.module: pybindRelated to our Python bindings / interactions with other Python librariestriagedThis issue has been looked at a team member, and triaged and prioritized into an appropriate module
Python 3.7 introduced the METH_FASTCALL and METH_FASTCALL | METH_KEYWORDS binding methods. (API) They skip tuple/dict construction and simply pass C arrays, and based on my testing in #48965 can save ~15ns compared to METH_VARARGS. (I have not tested the kwargs version, but I would expect skipping a dictionary to be even better.)
Pitch
#48965 adds a wrapper in python_compat.h so that we can rewrite endpoints to use _PyCFunctionFast but fall back to tuple wrapping for 3.6. This would need to be applied to all varargs functions and an analog would need to be written for functions that take kwargs. Given that most binding comes from the torch python arg parser, that will likely need to be converted as well. (I'm not sure how much work that would be.)
featureA request for a proper, new feature.module: pybindRelated to our Python bindings / interactions with other Python librariestriagedThis issue has been looked at a team member, and triaged and prioritized into an appropriate module
Activity
mrshenli commentedon Dec 18, 2020
adding "triage review" to discuss plans
VitalyFedyunin commentedon Dec 28, 2020
Good to go as per discussion.
Use METH_FASTCALL for Inductor C++ Python bindings (#192287)
Use METH_FASTCALL for Inductor C++ Python bindings (pytorch#192287)