summaryrefslogtreecommitdiffstats
path: root/Include/abstract.h
Commit message (Collapse)AuthorAgeFilesLines
* bpo-35134: Create Include/cpython/abstract.h (GH-10728)Victor Stinner2018-11-261-281/+4
| | | | Move abstract.h code surrounded by "#ifndef Py_LIMITED_API" to a new Include/cpython/abstract.h header file.
* Clean up after bpo-33738. (GH-7627)Serhiy Storchaka2018-06-111-4/+2
| | | | | * Add declarations even if they are overridden by macros. * Make the declaration and the definition of PyExceptionClass_Name consistent.
* bpo-33738: Address review comments in GH #7477 (GH-7585)Christian Tismer2018-06-101-1/+1
|
* bpo-33738: Fix macros which contradict PEP 384 (GH-7477)Christian Tismer2018-06-091-0/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | During development of the limited API support for PySide, we saw an error in a macro that accessed a type field. This patch fixes the 7 errors in the Python headers. Macros which were not written as capitals were implemented as function. To do the necessary analysis again, a script was included that parses all headers and looks for "->tp_" in serctions which can be reached with active limited API. It is easily possible to call this script as a test. Error listing: ../../Include/objimpl.h:243 #define PyObject_IS_GC(o) (PyType_IS_GC(Py_TYPE(o)) && \ (Py_TYPE(o)->tp_is_gc == NULL || Py_TYPE(o)->tp_is_gc(o))) Action: commented only ../../Include/objimpl.h:362 #define PyType_SUPPORTS_WEAKREFS(t) ((t)->tp_weaklistoffset > 0) Action: commented only ../../Include/objimpl.h:364 #define PyObject_GET_WEAKREFS_LISTPTR(o) \ ((PyObject **) (((char *) (o)) + Py_TYPE(o)->tp_weaklistoffset)) Action: commented only ../../Include/pyerrors.h:143 #define PyExceptionClass_Name(x) \ ((char *)(((PyTypeObject*)(x))->tp_name)) Action: implemented function ../../Include/abstract.h:593 #define PyIter_Check(obj) \ ((obj)->ob_type->tp_iternext != NULL && \ (obj)->ob_type->tp_iternext != &_PyObject_NextNotImplemented) Action: implemented function ../../Include/abstract.h:713 #define PyIndex_Check(obj) \ ((obj)->ob_type->tp_as_number != NULL && \ (obj)->ob_type->tp_as_number->nb_index != NULL) Action: implemented function ../../Include/abstract.h:924 #define PySequence_ITEM(o, i)\ ( Py_TYPE(o)->tp_as_sequence->sq_item(o, i) ) Action: commented only
* bpo-5945: Improve mappings and sequences C API docs. (GH-7029)Serhiy Storchaka2018-05-221-8/+8
|
* Fix PyObject_Hash signature in comment (#4905)Andrew Svetlov2017-12-161-1/+1
|
* bpo-32240: Add the const qualifier to declarations of PyObject* array ↵Serhiy Storchaka2017-12-151-8/+8
| | | | arguments. (#4746)
* Spelling fixes (#2902)Ville Skyttä2017-08-031-1/+1
|
* bpo-29852: Argument Clinic Py_ssize_t converter now supports None (#716)Serhiy Storchaka2017-03-301-0/+3
| | | if pass `accept={int, NoneType}`.
* bpo-29735: Optimize partial_call(): avoid tuple (#516)Victor Stinner2017-03-141-0/+4
| | | | | | | | * Add _PyObject_HasFastCall() * partial_call() now avoids temporary tuple to pass positional arguments if the callable supports the FASTCALL calling convention for positional arguments. * Fix also a performance regression in partial_call() if the callable doesn't support FASTCALL.
* Optimize slots: avoid temporary PyMethodObjectVictor Stinner2017-02-091-0/+6
| | | | | | | | | | | | | | | | | | Issue #29507: Optimize slots calling Python methods. For Python methods, get the unbound Python function and prepend arguments with self, rather than calling the descriptor which creates a temporary PyMethodObject. Add a new _PyObject_FastCall_Prepend() function used to call the unbound Python method with self. It avoids the creation of a temporary tuple to pass positional arguments. Avoiding temporary PyMethodObject and avoiding temporary tuple makes Python slots up to 1.46x faster. Microbenchmark on a __getitem__() method implemented in Python: Median +- std dev: 121 ns +- 5 ns -> 82.8 ns +- 1.0 ns: 1.46x faster (-31%) Co-Authored-by: INADA Naoki <songofacandy@gmail.com>
* Issue #29360: _PyStack_AsDict() doesn't check kwnamesVictor Stinner2017-01-241-6/+9
| | | | | Remove two assertions which can fail on legit code. Keyword arguments are checked later with better tests and raise a regular (TypeError) exception.
* Remove unused func parameter of _PyStack_UnpackDict()Victor Stinner2017-01-181-2/+1
| | | | Issue #29259.
* _PyStack_UnpackDict() now returns -1 on errorVictor Stinner2017-01-171-5/+8
| | | | | Issue #29286. Change _PyStack_UnpackDict() prototype to be able to notify of failure when args is NULL.
* Rename _PyArg_ParseStack to _PyArg_ParseStackAndKeywordsVictor Stinner2017-01-171-2/+2
| | | | Issue #29286.
* Add _PyStack_AsTupleSlice() helperVictor Stinner2017-01-161-0/+6
|
* call_method() now uses _PyObject_FastCall()Victor Stinner2017-01-101-8/+0
| | | | | | | | | | | | | | | | | | | Issue #29233: Replace the inefficient _PyObject_VaCallFunctionObjArgs() with _PyObject_FastCall() in call_method() and call_maybe(). Only a few functions call call_method() and call it with a fixed number of arguments. Avoid the complex and expensive _PyObject_VaCallFunctionObjArgs() function, replace it with an array allocated on the stack with the exact number of argumlents. It reduces the stack consumption, bytes per call, before => after: test_python_call: 1168 => 1152 (-16 B) test_python_getitem: 1344 => 1008 (-336 B) test_python_iterator: 1568 => 1232 (-336 B) Remove the _PyObject_VaCallFunctionObjArgs() function which became useless. Rename it to object_vacall() and make it private.
* Issue #29058: All stable API extensions added after Python 3.2 are nowSerhiy Storchaka2016-12-271-0/+4
|\ | | | | | | | | available only when Py_LIMITED_API is set to the PY_VERSION_HEX value of the minimum Python version supporting this API.
| * Issue #29058: All stable API extensions added after Python 3.2 are nowSerhiy Storchaka2016-12-271-0/+4
| | | | | | | | | | available only when Py_LIMITED_API is set to the PY_VERSION_HEX value of the minimum Python version supporting this API.
* | abstract.h: remove long outdated commentVictor Stinner2016-12-191-118/+2
| | | | | | | | | | | | | | Issue #28838: The documentation is of the Python C API is more complete and more up to date than this old comment. Removal suggested by Antoine Pitrou.
* | Add _PY_FASTCALL_SMALL_STACK constantVictor Stinner2016-12-151-0/+11
| | | | | | | | | | | | | | | | | | Issue #28870: Add a new _PY_FASTCALL_SMALL_STACK constant, size of "small stacks" allocated on the C stack to pass positional arguments to _PyObject_FastCall(). _PyObject_Call_Prepend() now uses a small stack of 5 arguments (40 bytes) instead of 8 (64 bytes), since it is modified to use _PY_FASTCALL_SMALL_STACK.
* | Issue #28838: Cleanup abstract.hVictor Stinner2016-12-151-621/+423
| | | | | | | | | | | | | | | | | | | | Rewrite all comments to use the same style than other Python header files: comment functions *before* their declaration, no newline between the comment and the declaration. Reformat some comments, add newlines, to make them easier to read. Quote argument like 'arg' to mention an argument in a comment.
* | Add _PyObject_VaCallFunctionObjArgs() private functionVictor Stinner2016-12-081-0/+6
| | | | | | | | | | Issue #28915: Similar to _PyObject_CallFunctionObjArgs() but use va_list to pass arguments.
* | Issue #28838: Fix weird indentation of abstract.hVictor Stinner2016-12-061-847/+859
| | | | | | | | Remove most indentation to move code at the left.
* | Uniformize argument names of "call" functionsVictor Stinner2016-12-061-65/+67
| | | | | | | | | | | | | | | | | | | | | | | | Issue #28838: Rename parameters of the "calls" functions of the Python C API. * Rename 'callable_object' and 'func' to 'callable': any Python callable object is accepted, not only Python functions * Rename 'method' and 'nameid' to 'name' (method name) * Rename 'o' to 'obj' * Move, fix and update documentation of PyObject_CallXXX() functions in abstract.h * Update also the documentaton of the C API (update parameter names)
* | Fixed misplaced comment.Serhiy Storchaka2016-12-061-6/+6
|\ \ | |/
| * Fixed misplaced comment.Serhiy Storchaka2016-12-061-6/+6
| |\
| | * Fixed misplaced comment.Serhiy Storchaka2016-12-061-6/+6
| | |
* | | Issue #28858: Remove _PyObject_CallArg1() macroVictor Stinner2016-12-051-4/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Replace _PyObject_CallArg1(func, arg) with PyObject_CallFunctionObjArgs(func, arg, NULL) Using the _PyObject_CallArg1() macro increases the usage of the C stack, which was unexpected and unwanted. PyObject_CallFunctionObjArgs() doesn't have this issue.
* | | fix _PyObject_CallArg1 compiler warnings (closes #28855)Benjamin Peterson2016-12-021-1/+1
| | |
* | | Backed out changeset 7efddbf1aa70Victor Stinner2016-11-301-20/+20
| | |
* | | Uniformize argument names of "call" functionsVictor Stinner2016-11-291-20/+20
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Callable object: callable, o, callable_object => func * Object for method calls: o => obj * Method name: name or nameid => method Cleanup also the C code: * Don't initialize variables to NULL if they are not used before their first assignement * Add braces for readability
* | | Issue #19569: Compiler warnings are now emitted if use most of deprecatedSerhiy Storchaka2016-11-201-4/+8
|/ / | | | | | | functions.
* | Issues #25909, #28211: Restored correct documentation of PyMapping_Items,Serhiy Storchaka2016-09-261-7/+7
|\ \ | |/ | | | | PyMapping_Keys and PyMapping_Values. Based on patch by Xiang Zhang.
| * Issues #25909, #28211: Restored correct documentation of PyMapping_Items,Serhiy Storchaka2016-09-261-7/+7
| | | | | | | | PyMapping_Keys and PyMapping_Values. Based on patch by Xiang Zhang.
| * Issue #27895: Spelling fixes (Contributed by Ville Skyttä).Martin Panter2016-09-071-1/+1
| |
* | Document kwnames in _PyObject_FastCallKeywords() and _PyStack_AsDict()Victor Stinner2016-09-121-30/+40
| | | | | | | | Issue #27213.
* | Revert change f860b7a775c5Victor Stinner2016-09-121-3/+1
| | | | | | | | | | Revert change "Issue #27213: Reintroduce checks in _PyStack_AsDict()", pushed by mistake.
* | ssue #27213: Reintroduce checks in _PyStack_AsDict()Victor Stinner2016-09-121-1/+3
| |
* | Issue #27213: Fixed different issues with reworked CALL_FUNCTION* opcodes.Serhiy Storchaka2016-09-111-3/+1
| | | | | | | | | | | | | | | | | | | | | | * 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.
* | Issue #26900: Excluded underscored names and other private API from limited API.Serhiy Storchaka2016-09-111-1/+9
| |
* | Add METH_FASTCALL calling conventionVictor Stinner2016-09-101-0/+16
| | | | | | | | | | | | | | | | | | | | | | 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.
* | Issue #27810: Add _PyCFunction_FastCallKeywords()Victor Stinner2016-09-091-1/+8
| | | | | | | | | | 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.
* | Add _PyObject_FastCallKeywords()Victor Stinner2016-09-091-2/+20
| | | | | | | | | | | | | | | | | | | | 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()
* | Issue #27895: Spelling fixes (Contributed by Ville Skyttä).Raymond Hettinger2016-08-301-1/+1
| |
* | Issue #27830: Revert, remove _PyFunction_FastCallKeywords()Victor Stinner2016-08-251-17/+0
| |
* | method_call() and slot_tp_new() now uses fast callVictor Stinner2016-08-241-0/+4
| | | | | | | | | | | | | | 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().
* | Add _PyObject_FastCallKeywords()Victor Stinner2016-08-241-0/+17
| | | | | | | | | | | | 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.
* | Use Py_ssize_t type for number of argumentsVictor Stinner2016-08-241-1/+1
| | | | | | | | | | Issue #27848: use Py_ssize_t rather than C int for the number of function positional and keyword arguments.
* | Rename _PyObject_FastCall() to _PyObject_FastCallDict()Victor Stinner2016-08-221-4/+13
| | | | | | | | | | | | | | | | Issue #27809: * Rename _PyObject_FastCall() function to _PyObject_FastCallDict() * Add _PyObject_FastCall(), _PyObject_CallNoArg() and _PyObject_CallArg1() macros calling _PyObject_FastCallDict()