diff options
author | Victor Stinner <victor.stinner@gmail.com> | 2016-09-09 19:36:44 (GMT) |
---|---|---|
committer | Victor Stinner <victor.stinner@gmail.com> | 2016-09-09 19:36:44 (GMT) |
commit | d8735720955557d8056bc1fca41ad1c3b48aa63c (patch) | |
tree | 87c04970bcbbd4ff7fd9b3c4ff5f138d98b7dc1e /Include | |
parent | 84f6a8f725c0f7a06d5e77b283d6028bf854443c (diff) | |
download | cpython-d8735720955557d8056bc1fca41ad1c3b48aa63c.zip cpython-d8735720955557d8056bc1fca41ad1c3b48aa63c.tar.gz cpython-d8735720955557d8056bc1fca41ad1c3b48aa63c.tar.bz2 |
Add _PyObject_FastCallKeywords()
Issue #27830: Add _PyObject_FastCallKeywords(): avoid the creation of a
temporary dictionary for keyword arguments.
Other changes:
* Cleanup call_function() and fast_function() (ex: rename nk to nkwargs)
* Remove now useless do_call(), replaced with _PyObject_FastCallKeywords()
Diffstat (limited to 'Include')
-rw-r--r-- | Include/abstract.h | 22 | ||||
-rw-r--r-- | Include/funcobject.h | 6 |
2 files changed, 26 insertions, 2 deletions
diff --git a/Include/abstract.h b/Include/abstract.h index e728b12..f709434 100644 --- a/Include/abstract.h +++ b/Include/abstract.h @@ -271,8 +271,8 @@ xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx*/ Py_ssize_t nargs); /* Call the callable object func with the "fast call" calling convention: - args is a C array for positional parameters (nargs is the number of - positional paramater), kwargs is a dictionary for keyword parameters. + args is a C array for positional arguments (nargs is the number of + positional arguments), kwargs is a dictionary for keyword arguments. If nargs is equal to zero, args can be NULL. kwargs can be NULL. nargs must be greater or equal to zero. @@ -283,6 +283,24 @@ xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx*/ PyObject **args, Py_ssize_t nargs, PyObject *kwargs); + /* Call the callable object func with the "fast call" calling convention: + args is a C array for positional arguments followed by values of + keyword arguments. Keys of keyword arguments are stored as a tuple + of strings in kwnames. nargs is the number of positional parameters at + the beginning of stack. The size of kwnames gives the number of keyword + values in the stack after positional arguments. + + If nargs is equal to zero and there is no keyword argument (kwnames is + NULL or its size is zero), args can be NULL. + + Return the result on success. Raise an exception and return NULL on + error. */ + PyAPI_FUNC(PyObject *) _PyObject_FastCallKeywords + (PyObject *func, + PyObject **args, + Py_ssize_t nargs, + PyObject *kwnames); + #define _PyObject_FastCall(func, args, nargs) \ _PyObject_FastCallDict((func), (args), (nargs), NULL) diff --git a/Include/funcobject.h b/Include/funcobject.h index 6b89c86..77bb8c3 100644 --- a/Include/funcobject.h +++ b/Include/funcobject.h @@ -64,6 +64,12 @@ PyAPI_FUNC(PyObject *) _PyFunction_FastCallDict( PyObject **args, Py_ssize_t nargs, PyObject *kwargs); + +PyAPI_FUNC(PyObject *) _PyFunction_FastCallKeywords( + PyObject *func, + PyObject **stack, + Py_ssize_t nargs, + PyObject *kwnames); #endif /* Macros for direct access to these values. Type checks are *not* |