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 of argument clinic like parsing and METH_FASTCALL support in extension modules #83528
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
assignee=Noneclosed_at=Nonecreated_at=<Date2020-01-15.21:03:38.635>labels= ['type-feature', 'expert-argument-clinic']
title='Use of argument clinic like parsing and `METH_FASTCALL` support in extension modules'updated_at=<Date2020-01-15.21:03:38.635>user='https://github.com/seberg'
This is mainly an information request, so sorry if its a bit besides the point (I do not mind if you just close it). But it seemed a bit too specific to get answers in most places...
In Python you use argument clinic, which supports METH_FASTCALL, that seems pretty awesome.
For extension modules, I am not sure that argument clinic is a straight forward choice, since it probably generates code specific to a single Python version and also using, while we need to support multiple versions (including versions that do not support METH_FASTCALL.
So the question would be if there is some idea for providing such C-API, or for example exposing _PyArg_UnpackKeywords (which is at the heart of kwarg parsing).
My use-case is that some NumPy functions do have a nice speedup when using METH_FASTCALL and better argument clinic style faster arg-parsing. Which is why, looking at these things, I practically reimplemented a slightly dumbed down version of PyArg_ParseTupleAndKeywords working much like argument clinic (except less smart and only using macros and no code generation).
That seems viable, but also feels a bit wrong, so I am curious if there may be a better solution or whether it would be plausible to expose _PyArg_UnpackKeywords to reduce code duplication. (although I suppose due to old python version support that would effectively take years)
For completeness, my code in question is here: numpy/numpy#15269 with the actual usage pattern being:
Activity
seberg commentedon Jan 15, 2020
This is mainly an information request, so sorry if its a bit besides the point (I do not mind if you just close it). But it seemed a bit too specific to get answers in most places...
In Python you use argument clinic, which supports
METH_FASTCALL, that seems pretty awesome.For extension modules, I am not sure that argument clinic is a straight forward choice, since it probably generates code specific to a single Python version and also using, while we need to support multiple versions (including versions that do not support
METH_FASTCALL.So the question would be if there is some idea for providing such C-API, or for example exposing
_PyArg_UnpackKeywords(which is at the heart of kwarg parsing).My use-case is that some NumPy functions do have a nice speedup when using
METH_FASTCALLand better argument clinic style faster arg-parsing. Which is why, looking at these things, I practically reimplemented a slightly dumbed down version ofPyArg_ParseTupleAndKeywordsworking much like argument clinic (except less smart and only using macros and no code generation).That seems viable, but also feels a bit wrong, so I am curious if there may be a better solution or whether it would be plausible to expose
_PyArg_UnpackKeywordsto reduce code duplication. (although I suppose due to old python version support that would effectively take years)For completeness, my code in question is here: numpy/numpy#15269 with the actual usage pattern being: