Skip to content

Commit 3191391

Browse files
bpo-36127: Argument Clinic: inline parsing code for keyword parameters. (GH-12058)
1 parent 2c0d3f4 commit 3191391

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+7461
-863
lines changed

Doc/whatsnew/3.8.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -442,6 +442,11 @@ Optimizations
442442
(Contributed by Stefan Behnel, Pablo Galindo Salgado, Raymond Hettinger,
443443
Neil Schemenauer, and Serhiy Storchaka in :issue:`36012`.)
444444

445+
* Reduced an overhead of converting arguments passed to many builtin functions
446+
and methods. This sped up calling some simple builtin functions and
447+
methods up to 20--50%. (Contributed by Serhiy Storchaka in :issue:`23867`,
448+
:issue:`35582` and :issue:`36127`.)
449+
445450

446451
Build and C API Changes
447452
=======================

Include/modsupport.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,18 @@ PyAPI_FUNC(int) _PyArg_ParseStackAndKeywords(
118118
...);
119119
PyAPI_FUNC(int) _PyArg_VaParseTupleAndKeywordsFast(PyObject *, PyObject *,
120120
struct _PyArg_Parser *, va_list);
121+
PyAPI_FUNC(PyObject * const *) _PyArg_UnpackKeywords(
122+
PyObject *const *args, Py_ssize_t nargs,
123+
PyObject *kwargs, PyObject *kwnames,
124+
struct _PyArg_Parser *parser,
125+
int minpos, int maxpos, int minkw,
126+
PyObject **buf);
127+
#define _PyArg_UnpackKeywords(args, nargs, kwargs, kwnames, parser, minpos, maxpos, minkw, buf) \
128+
(((minkw) == 0 && (kwargs) == NULL && (kwnames) == NULL && \
129+
(minpos) <= (nargs) && (nargs) <= (maxpos) && args != NULL) ? (args) : \
130+
_PyArg_UnpackKeywords((args), (nargs), (kwargs), (kwnames), (parser), \
131+
(minpos), (maxpos), (minkw), (buf)))
132+
121133
void _PyArg_Fini(void);
122134
#endif /* Py_LIMITED_API */
123135

0 commit comments

Comments
 (0)