From d7a4362203dbd80afd88e89b46e649d7c3095821 Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Fri, 19 Aug 2016 16:11:43 +0200 Subject: Add _PyObject_FastCall() Issue #27128: Add _PyObject_FastCall(), a new calling convention avoiding a temporary tuple to pass positional parameters in most cases, but create a temporary tuple if needed (ex: for the tp_call slot). The API is prepared to support keyword parameters, but the full implementation will come later (_PyFunction_FastCall() doesn't support keyword parameters yet). Add also: * _PyStack_AsTuple() helper function: convert a "stack" of parameters to a tuple. * _PyCFunction_FastCall(): fast call implementation for C functions * _PyFunction_FastCall(): fast call implementation for Python functions --- Include/abstract.h | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'Include/abstract.h') diff --git a/Include/abstract.h b/Include/abstract.h index 4ff79f2928..280402cae3 100644 --- a/Include/abstract.h +++ b/Include/abstract.h @@ -267,10 +267,26 @@ xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx*/ PyObject *args, PyObject *kw); #ifndef Py_LIMITED_API + PyAPI_FUNC(PyObject*) _PyStack_AsTuple(PyObject **stack, + 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. + + If nargs is equal to zero, args can be NULL. kwargs can be NULL. + nargs must be greater or equal to zero. + + Return the result on success. Raise an exception on return NULL on + error. */ + PyAPI_FUNC(PyObject *) _PyObject_FastCall(PyObject *func, + PyObject **args, int nargs, + PyObject *kwargs); + PyAPI_FUNC(PyObject *) _Py_CheckFunctionResult(PyObject *func, PyObject *result, const char *where); -#endif +#endif /* Py_LIMITED_API */ /* Call a callable Python object, callable_object, with -- cgit v1.2.1 From 06f5b1d3dd2314af2e1f97e8da45bb28b0969f5e Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Fri, 19 Aug 2016 17:12:23 +0200 Subject: Fix PyObject_Call() parameter names Issue #27128: arg=>args, kw=>kwargs. Same change for PyEval_CallObjectWithKeywords(). --- Include/abstract.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Include/abstract.h') diff --git a/Include/abstract.h b/Include/abstract.h index 280402cae3..f67c6b2159 100644 --- a/Include/abstract.h +++ b/Include/abstract.h @@ -264,7 +264,7 @@ xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx*/ */ PyAPI_FUNC(PyObject *) PyObject_Call(PyObject *callable_object, - PyObject *args, PyObject *kw); + PyObject *args, PyObject *kwargs); #ifndef Py_LIMITED_API PyAPI_FUNC(PyObject*) _PyStack_AsTuple(PyObject **stack, -- cgit v1.2.1 From de03c6d8066496680a1ea99ff9e67e28852b0007 Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Mon, 22 Aug 2016 22:48:54 +0200 Subject: Rename _PyObject_FastCall() to _PyObject_FastCallDict() Issue #27809: * Rename _PyObject_FastCall() function to _PyObject_FastCallDict() * Add _PyObject_FastCall(), _PyObject_CallNoArg() and _PyObject_CallArg1() macros calling _PyObject_FastCallDict() --- Include/abstract.h | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'Include/abstract.h') diff --git a/Include/abstract.h b/Include/abstract.h index f67c6b2159..69c4890a9e 100644 --- a/Include/abstract.h +++ b/Include/abstract.h @@ -279,9 +279,18 @@ xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx*/ Return the result on success. Raise an exception on return NULL on error. */ - PyAPI_FUNC(PyObject *) _PyObject_FastCall(PyObject *func, - PyObject **args, int nargs, - PyObject *kwargs); + PyAPI_FUNC(PyObject *) _PyObject_FastCallDict(PyObject *func, + PyObject **args, int nargs, + PyObject *kwargs); + +#define _PyObject_FastCall(func, args, nargs) \ + _PyObject_FastCallDict((func), (args), (nargs), NULL) + +#define _PyObject_CallNoArg(func) \ + _PyObject_FastCall((func), NULL, 0) + +#define _PyObject_CallArg1(func, arg) \ + _PyObject_FastCall((func), &(arg), 1) PyAPI_FUNC(PyObject *) _Py_CheckFunctionResult(PyObject *func, PyObject *result, @@ -291,7 +300,7 @@ xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx*/ /* Call a callable Python object, callable_object, with arguments and keywords arguments. The 'args' argument can not be - NULL, but the 'kw' argument can be NULL. + NULL. */ PyAPI_FUNC(PyObject *) PyObject_CallObject(PyObject *callable_object, -- cgit v1.2.1 From c79e5123bcf2d1e514a0420e89c62fa334d57ba9 Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Thu, 25 Aug 2016 00:04:09 +0200 Subject: Use Py_ssize_t type for number of arguments Issue #27848: use Py_ssize_t rather than C int for the number of function positional and keyword arguments. --- Include/abstract.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Include/abstract.h') diff --git a/Include/abstract.h b/Include/abstract.h index 69c4890a9e..582086486b 100644 --- a/Include/abstract.h +++ b/Include/abstract.h @@ -280,7 +280,7 @@ xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx*/ Return the result on success. Raise an exception on return NULL on error. */ PyAPI_FUNC(PyObject *) _PyObject_FastCallDict(PyObject *func, - PyObject **args, int nargs, + PyObject **args, Py_ssize_t nargs, PyObject *kwargs); #define _PyObject_FastCall(func, args, nargs) \ -- cgit v1.2.1 From 5f2acb2c1a143794ef61db34590ceee4b2d89680 Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Thu, 25 Aug 2016 00:29:32 +0200 Subject: Add _PyObject_FastCallKeywords() Issue #27830: Similar to _PyObject_FastCallDict(), but keyword arguments are also passed in the same C array than positional arguments, rather than being passed as a Python dict. --- Include/abstract.h | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'Include/abstract.h') diff --git a/Include/abstract.h b/Include/abstract.h index 582086486b..474d7468e7 100644 --- a/Include/abstract.h +++ b/Include/abstract.h @@ -292,6 +292,23 @@ xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx*/ #define _PyObject_CallArg1(func, arg) \ _PyObject_FastCall((func), &(arg), 1) + /* Call the callable object func with the "fast call" calling convention: + args is a C array for positional arguments followed by (key, value) + pairs for keyword arguments. + + nargs is the number of positional parameters at the beginning of stack. + nkwargs is the number of (key, value) pairs at the end of stack. + + If nargs and nkwargs are equal to zero, stack can be NULL. + + Return the result on success. Raise an exception and return NULL on + error. */ + PyAPI_FUNC(PyObject *) _PyObject_FastCallKeywords( + PyObject *func, + PyObject **stack, + Py_ssize_t nargs, + Py_ssize_t nkwargs); + PyAPI_FUNC(PyObject *) _Py_CheckFunctionResult(PyObject *func, PyObject *result, const char *where); -- cgit v1.2.1 From 1de419b3db8739947ef8c2fe36ce3944d8576fd5 Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Thu, 25 Aug 2016 01:04:14 +0200 Subject: method_call() and slot_tp_new() now uses fast call Issue #27841: Add _PyObject_Call_Prepend() helper function to prepend an argument to existing arguments to call a function. This helper uses fast calls. Modify method_call() and slot_tp_new() to use _PyObject_Call_Prepend(). --- Include/abstract.h | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'Include/abstract.h') diff --git a/Include/abstract.h b/Include/abstract.h index 474d7468e7..ebad84b30e 100644 --- a/Include/abstract.h +++ b/Include/abstract.h @@ -309,6 +309,10 @@ xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx*/ Py_ssize_t nargs, Py_ssize_t nkwargs); + PyAPI_FUNC(PyObject *) _PyObject_Call_Prepend(PyObject *func, + PyObject *obj, PyObject *args, + PyObject *kwargs); + PyAPI_FUNC(PyObject *) _Py_CheckFunctionResult(PyObject *func, PyObject *result, const char *where); -- cgit v1.2.1 From 2c15df27be9ecb04e0c14313de88a6d9299cb261 Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Thu, 25 Aug 2016 23:26:50 +0200 Subject: Issue #27830: Revert, remove _PyFunction_FastCallKeywords() --- Include/abstract.h | 17 ----------------- 1 file changed, 17 deletions(-) (limited to 'Include/abstract.h') diff --git a/Include/abstract.h b/Include/abstract.h index ebad84b30e..f838b50b6e 100644 --- a/Include/abstract.h +++ b/Include/abstract.h @@ -292,23 +292,6 @@ xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx*/ #define _PyObject_CallArg1(func, arg) \ _PyObject_FastCall((func), &(arg), 1) - /* Call the callable object func with the "fast call" calling convention: - args is a C array for positional arguments followed by (key, value) - pairs for keyword arguments. - - nargs is the number of positional parameters at the beginning of stack. - nkwargs is the number of (key, value) pairs at the end of stack. - - If nargs and nkwargs are equal to zero, stack can be NULL. - - Return the result on success. Raise an exception and return NULL on - error. */ - PyAPI_FUNC(PyObject *) _PyObject_FastCallKeywords( - PyObject *func, - PyObject **stack, - Py_ssize_t nargs, - Py_ssize_t nkwargs); - PyAPI_FUNC(PyObject *) _PyObject_Call_Prepend(PyObject *func, PyObject *obj, PyObject *args, PyObject *kwargs); -- cgit v1.2.1 From 4846ba81c69ebc815b35a89ed54fef7b5ffb1417 Mon Sep 17 00:00:00 2001 From: Raymond Hettinger Date: Tue, 30 Aug 2016 10:47:49 -0700 Subject: Issue #27895: Spelling fixes (Contributed by Ville Skytt?). --- Include/abstract.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Include/abstract.h') diff --git a/Include/abstract.h b/Include/abstract.h index f838b50b6e..e728b121f4 100644 --- a/Include/abstract.h +++ b/Include/abstract.h @@ -487,7 +487,7 @@ xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx*/ /* old buffer API FIXME: usage of these should all be replaced in Python itself but for backwards compatibility we will implement them. - Their usage without a corresponding "unlock" mechansim + Their usage without a corresponding "unlock" mechanism may create issues (but they would already be there). */ PyAPI_FUNC(int) PyObject_AsCharBuffer(PyObject *obj, -- cgit v1.2.1 From 90854a874a441fd07a196e9e8a4a8b6c1ff0e670 Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Fri, 9 Sep 2016 12:36:44 -0700 Subject: 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() --- Include/abstract.h | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) (limited to 'Include/abstract.h') diff --git a/Include/abstract.h b/Include/abstract.h index e728b121f4..f709434087 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) -- cgit v1.2.1 From 2615f24fb54cece9f22c5e2b1d206e8dd559631a Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Fri, 9 Sep 2016 14:07:44 -0700 Subject: Issue #27810: Add _PyCFunction_FastCallKeywords() Use _PyCFunction_FastCallKeywords() in ceval.c: it allows to remove a lot of code from ceval.c which was only used to call C functions. --- Include/abstract.h | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'Include/abstract.h') diff --git a/Include/abstract.h b/Include/abstract.h index f709434087..3f398daa00 100644 --- a/Include/abstract.h +++ b/Include/abstract.h @@ -267,9 +267,16 @@ xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx*/ PyObject *args, PyObject *kwargs); #ifndef Py_LIMITED_API - PyAPI_FUNC(PyObject*) _PyStack_AsTuple(PyObject **stack, + PyAPI_FUNC(PyObject*) _PyStack_AsTuple( + PyObject **stack, Py_ssize_t nargs); + PyAPI_FUNC(PyObject *) _PyStack_AsDict( + PyObject **values, + Py_ssize_t nkwargs, + PyObject *kwnames, + PyObject *func); + /* Call the callable object func with the "fast call" calling convention: args is a C array for positional arguments (nargs is the number of positional arguments), kwargs is a dictionary for keyword arguments. -- cgit v1.2.1 From 14e79902895c8f92b5cf80483619fac1e3832425 Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Fri, 9 Sep 2016 17:40:22 -0700 Subject: Add METH_FASTCALL calling convention Issue #27810: Add a new calling convention for C functions: PyObject* func(PyObject *self, PyObject **args, Py_ssize_t nargs, PyObject *kwnames); Where args is a C array of positional arguments followed by values of keyword arguments. nargs is the number of positional arguments, kwnames are keys of keyword arguments. kwnames can be NULL. --- Include/abstract.h | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'Include/abstract.h') diff --git a/Include/abstract.h b/Include/abstract.h index 3f398daa00..3e630b1837 100644 --- a/Include/abstract.h +++ b/Include/abstract.h @@ -277,6 +277,22 @@ xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx*/ PyObject *kwnames, PyObject *func); + /* Convert (args, nargs, kwargs) into a (stack, nargs, kwnames). + + Return a new stack which should be released by PyMem_Free(), or return + args unchanged if kwargs is NULL or an empty dictionary. + + The stack uses borrowed references. + + The type of keyword keys is not checked, these checks should be done + later (ex: _PyArg_ParseStack). */ + PyAPI_FUNC(PyObject **) _PyStack_UnpackDict( + PyObject **args, + Py_ssize_t nargs, + PyObject *kwargs, + PyObject **kwnames, + PyObject *func); + /* Call the callable object func with the "fast call" calling convention: args is a C array for positional arguments (nargs is the number of positional arguments), kwargs is a dictionary for keyword arguments. -- cgit v1.2.1 From 97b3ef45e988a2ede5143dbf716991ca621a0914 Mon Sep 17 00:00:00 2001 From: Serhiy Storchaka Date: Sun, 11 Sep 2016 11:03:14 +0300 Subject: Issue #26900: Excluded underscored names and other private API from limited API. --- Include/abstract.h | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'Include/abstract.h') diff --git a/Include/abstract.h b/Include/abstract.h index 3e630b1837..87483677fd 100644 --- a/Include/abstract.h +++ b/Include/abstract.h @@ -7,7 +7,9 @@ extern "C" { #ifdef PY_SSIZE_T_CLEAN #define PyObject_CallFunction _PyObject_CallFunction_SizeT #define PyObject_CallMethod _PyObject_CallMethod_SizeT +#ifndef Py_LIMITED_API #define _PyObject_CallMethodId _PyObject_CallMethodId_SizeT +#endif /* !Py_LIMITED_API */ #endif /* Abstract Object Interface (many thanks to Jim Fulton) */ @@ -385,6 +387,7 @@ xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx*/ Python expression: o.method(args). */ +#ifndef Py_LIMITED_API PyAPI_FUNC(PyObject *) _PyObject_CallMethodId(PyObject *o, _Py_Identifier *method, const char *format, ...); @@ -393,6 +396,7 @@ xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx*/ Like PyObject_CallMethod, but expect a _Py_Identifier* as the method name. */ +#endif /* !Py_LIMITED_API */ PyAPI_FUNC(PyObject *) _PyObject_CallFunction_SizeT(PyObject *callable, const char *format, @@ -401,10 +405,12 @@ xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx*/ const char *name, const char *format, ...); +#ifndef Py_LIMITED_API PyAPI_FUNC(PyObject *) _PyObject_CallMethodId_SizeT(PyObject *o, _Py_Identifier *name, const char *format, ...); +#endif /* !Py_LIMITED_API */ PyAPI_FUNC(PyObject *) PyObject_CallFunctionObjArgs(PyObject *callable, ...); @@ -420,9 +426,11 @@ xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx*/ PyAPI_FUNC(PyObject *) PyObject_CallMethodObjArgs(PyObject *o, PyObject *method, ...); +#ifndef Py_LIMITED_API PyAPI_FUNC(PyObject *) _PyObject_CallMethodIdObjArgs(PyObject *o, struct _Py_Identifier *method, ...); +#endif /* !Py_LIMITED_API */ /* Call the method named m of object o with a variable number of @@ -1340,13 +1348,13 @@ PyAPI_FUNC(int) _PyObject_RealIsSubclass(PyObject *derived, PyObject *cls); PyAPI_FUNC(char *const *) _PySequence_BytesToCharpArray(PyObject* self); PyAPI_FUNC(void) _Py_FreeCharPArray(char *const array[]); -#endif /* For internal use by buffer API functions */ PyAPI_FUNC(void) _Py_add_one_to_index_F(int nd, Py_ssize_t *index, const Py_ssize_t *shape); PyAPI_FUNC(void) _Py_add_one_to_index_C(int nd, Py_ssize_t *index, const Py_ssize_t *shape); +#endif /* !Py_LIMITED_API */ #ifdef __cplusplus -- cgit v1.2.1 From e74d571e49d3fdb4389b79fa1392dd75e2acb916 Mon Sep 17 00:00:00 2001 From: Serhiy Storchaka Date: Mon, 12 Sep 2016 00:52:40 +0300 Subject: Issue #27213: Fixed different issues with reworked CALL_FUNCTION* opcodes. * BUILD_TUPLE_UNPACK and BUILD_MAP_UNPACK_WITH_CALL no longer generated with single tuple or dict. * Restored more informative error messages for incorrect var-positional and var-keyword arguments. * Removed code duplications in _PyEval_EvalCodeWithName(). * Removed redundant runtime checks and parameters in _PyStack_AsDict(). * Added a workaround and enabled previously disabled test in test_traceback. * Removed dead code from the dis module. --- Include/abstract.h | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'Include/abstract.h') diff --git a/Include/abstract.h b/Include/abstract.h index 87483677fd..a94ce660c0 100644 --- a/Include/abstract.h +++ b/Include/abstract.h @@ -275,9 +275,7 @@ xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx*/ PyAPI_FUNC(PyObject *) _PyStack_AsDict( PyObject **values, - Py_ssize_t nkwargs, - PyObject *kwnames, - PyObject *func); + PyObject *kwnames); /* Convert (args, nargs, kwargs) into a (stack, nargs, kwnames). -- cgit v1.2.1 From 2f777ef4d923e4c8ef9567d06d4959fc9bd3b8e9 Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Mon, 12 Sep 2016 12:55:28 +0200 Subject: ssue #27213: Reintroduce checks in _PyStack_AsDict() --- Include/abstract.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'Include/abstract.h') diff --git a/Include/abstract.h b/Include/abstract.h index a94ce660c0..87483677fd 100644 --- a/Include/abstract.h +++ b/Include/abstract.h @@ -275,7 +275,9 @@ xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx*/ PyAPI_FUNC(PyObject *) _PyStack_AsDict( PyObject **values, - PyObject *kwnames); + Py_ssize_t nkwargs, + PyObject *kwnames, + PyObject *func); /* Convert (args, nargs, kwargs) into a (stack, nargs, kwnames). -- cgit v1.2.1 From 92011c90edeea1c883b0811039c3c9d102ccfbd9 Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Mon, 12 Sep 2016 13:30:02 +0200 Subject: Revert change f860b7a775c5 Revert change "Issue #27213: Reintroduce checks in _PyStack_AsDict()", pushed by mistake. --- Include/abstract.h | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'Include/abstract.h') diff --git a/Include/abstract.h b/Include/abstract.h index 87483677fd..a94ce660c0 100644 --- a/Include/abstract.h +++ b/Include/abstract.h @@ -275,9 +275,7 @@ xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx*/ PyAPI_FUNC(PyObject *) _PyStack_AsDict( PyObject **values, - Py_ssize_t nkwargs, - PyObject *kwnames, - PyObject *func); + PyObject *kwnames); /* Convert (args, nargs, kwargs) into a (stack, nargs, kwnames). -- cgit v1.2.1 From af28671b2c1ff0e7b5c27f588b5620de8d17e676 Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Mon, 12 Sep 2016 13:37:07 +0200 Subject: Document kwnames in _PyObject_FastCallKeywords() and _PyStack_AsDict() Issue #27213. --- Include/abstract.h | 70 +++++++++++++++++++++++++++++++----------------------- 1 file changed, 40 insertions(+), 30 deletions(-) (limited to 'Include/abstract.h') diff --git a/Include/abstract.h b/Include/abstract.h index a94ce660c0..3e8ca1f48e 100644 --- a/Include/abstract.h +++ b/Include/abstract.h @@ -273,6 +273,13 @@ xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx*/ PyObject **stack, Py_ssize_t nargs); + /* Convert keyword arguments from the (stack, kwnames) format to a Python + dictionary. + + kwnames must only contains str strings, no subclass, and all keys must + be unique. kwnames is not checked, usually these checks are done before or later + calling _PyStack_AsDict(). For example, _PyArg_ParseStack() raises an + error if a key is not a string. */ PyAPI_FUNC(PyObject *) _PyStack_AsDict( PyObject **values, PyObject *kwnames); @@ -293,36 +300,39 @@ xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx*/ PyObject **kwnames, PyObject *func); - /* Call the callable object func with the "fast call" calling convention: - 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. - - Return the result on success. Raise an exception on return NULL on - error. */ - PyAPI_FUNC(PyObject *) _PyObject_FastCallDict(PyObject *func, - 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); + /* Call the callable object func with the "fast call" calling convention: + 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. + + Return the result on success. Raise an exception on return NULL on + error. */ + PyAPI_FUNC(PyObject *) _PyObject_FastCallDict(PyObject *func, + 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. + + kwnames must only contains str strings, no subclass, and all keys must + be unique. + + 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) -- cgit v1.2.1 From 88983fee9e51b919e0435b26f4df826ed7652bd0 Mon Sep 17 00:00:00 2001 From: Serhiy Storchaka Date: Tue, 27 Dec 2016 14:57:39 +0200 Subject: Issue #29058: All stable API extensions added after Python 3.2 are now available only when Py_LIMITED_API is set to the PY_VERSION_HEX value of the minimum Python version supporting this API. --- Include/abstract.h | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'Include/abstract.h') diff --git a/Include/abstract.h b/Include/abstract.h index 03f8dbbc4c..7d137a22bf 100644 --- a/Include/abstract.h +++ b/Include/abstract.h @@ -750,11 +750,13 @@ xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx*/ o1*o2. */ +#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03050000 PyAPI_FUNC(PyObject *) PyNumber_MatrixMultiply(PyObject *o1, PyObject *o2); /* This is the equivalent of the Python expression: o1 @ o2. */ +#endif PyAPI_FUNC(PyObject *) PyNumber_FloorDivide(PyObject *o1, PyObject *o2); @@ -930,11 +932,13 @@ xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx*/ o1 *= o2. */ +#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03050000 PyAPI_FUNC(PyObject *) PyNumber_InPlaceMatrixMultiply(PyObject *o1, PyObject *o2); /* This is the equivalent of the Python expression: o1 @= o2. */ +#endif PyAPI_FUNC(PyObject *) PyNumber_InPlaceFloorDivide(PyObject *o1, PyObject *o2); -- cgit v1.2.1