summaryrefslogtreecommitdiffstats
path: root/Objects/call.c
Commit message (Collapse)AuthorAgeFilesLines
* bpo-39245: Switch to public API for Vectorcall (GH-18460)Petr Viktorin2020-02-111-7/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | The bulk of this patch was generated automatically with: for name in \ PyObject_Vectorcall \ Py_TPFLAGS_HAVE_VECTORCALL \ PyObject_VectorcallMethod \ PyVectorcall_Function \ PyObject_CallOneArg \ PyObject_CallMethodNoArgs \ PyObject_CallMethodOneArg \ ; do echo $name git grep -lwz _$name | xargs -0 sed -i "s/\b_$name\b/$name/g" done old=_PyObject_FastCallDict new=PyObject_VectorcallDict git grep -lwz $old | xargs -0 sed -i "s/\b$old\b/$new/g" and then cleaned up: - Revert changes to in docs & news - Revert changes to backcompat defines in headers - Nudge misaligned comments
* bpo-39573: Use Py_TYPE() macro in Objects directory (GH-18392)Victor Stinner2020-02-071-2/+2
| | | Replace direct access to PyObject.ob_type with Py_TYPE().
* bpo-38644: Add _PyEval_EvalCode() (GH-17183)Victor Stinner2019-11-161-26/+29
| | | _PyFunction_Vectorcall() now pass tstate to function calls.
* bpo-38644: Add _PyObject_Call() (GH-17089)Victor Stinner2019-11-141-97/+125
| | | | | | | | | | * Add pycore_call.h internal header file. * Add _PyObject_Call(): PyObject_Call() with tstate * Add _PyObject_CallNoArgTstate(): _PyObject_CallNoArg() with tstate * Add _PyObject_FastCallDictTstate(): _PyObject_FastCallDict() with tstate * _PyObject_Call_Prepend() now takes tstate * Replace _PyObject_FastCall() calls with _PyObject_VectorcallTstate() calls
* bpo-38644: Add _PyEval_EvalFrame() with tstate (GH-17131)Victor Stinner2019-11-141-1/+2
| | | | Add _PyEval_EvalFrame() static inline function to get eval_frame from tstate->interp.
* bpo-38644: Add _PyObject_VectorcallTstate() (GH-17052)Victor Stinner2019-11-081-5/+7
| | | | | * Add _PyObject_VectorcallTstate() function: similar to _PyObject_Vectorcall(), but with tstate parameter * Add tstate parameter to _PyObject_MakeTpCall()
* bpo-38733: PyErr_Occurred() caller must hold the GIL (GH-17080)Victor Stinner2019-11-071-4/+2
| | | | | | | | | | | bpo-3605, bpo-38733: Optimize _PyErr_Occurred(): remove "tstate == NULL" test. Py_FatalError() no longer calls PyErr_Occurred() if called without holding the GIL. So PyErr_Occurred() no longer has to support tstate==NULL case. _Py_CheckFunctionResult(): use directly _PyErr_Occurred() to avoid explicit "!= NULL" test.
* bpo-38644: Pass tstate to _Py_CheckFunctionResult() (GH-17050)Victor Stinner2019-11-051-34/+47
| | | | | * Add tstate parameter to _Py_CheckFunctionResult() * Add _PyErr_FormatFromCauseTstate() * Replace PyErr_XXX(...) with _PyErr_XXX(state, ...)
* bpo-38644: Pass tstate to Py_EnterRecursiveCall() (GH-16997)Victor Stinner2019-11-041-19/+23
| | | | | | | | | | | | | * Add _Py_EnterRecursiveCall() and _Py_LeaveRecursiveCall() which require a tstate argument. * Pass tstate to _Py_MakeRecCheck() and _Py_CheckRecursiveCall(). * Convert Py_EnterRecursiveCall() and Py_LeaveRecursiveCall() macros to static inline functions. _PyThreadState_GET() is the most efficient way to get the tstate, and so using it with _Py_EnterRecursiveCall() and _Py_LeaveRecursiveCall() should be a little bit more efficient than using Py_EnterRecursiveCall() and Py_LeaveRecursiveCall() which use the "slower" PyThreadState_GET().
* bpo-37151: remove special case for PyCFunction from PyObject_Call (GH-14684)Jeroen Demeyer2019-09-111-62/+7
| | | | | | | bpo-37151: remove special case for PyCFunction from PyObject_Call Alse, make the undocumented function PyCFunction_Call an alias of PyObject_Call and deprecate it.
* bpo-37540: vectorcall: keyword names must be strings (GH-14682)Jeroen Demeyer2019-08-161-6/+19
| | | | | | | | The fact that keyword names are strings is now part of the vectorcall and `METH_FASTCALL` protocols. The biggest concrete change is that `_PyStack_UnpackDict` now checks that and raises `TypeError` if not. CC @markshannon @vstinner https://bugs.python.org/issue37540
* bpo-29548: no longer use PyEval_Call* functions (GH-14683)Jeroen Demeyer2019-07-111-1/+10
|
* bpo-37151: remove _PyMethodDef_RawFastCall* functions (GH-14603)Jeroen Demeyer2019-07-051-259/+0
|
* bpo-36974: separate vectorcall functions for each calling convention (GH-13781)Jeroen Demeyer2019-07-051-21/+1
|
* bpo-36904: Optimize _PyStack_UnpackDict (GH-14517)Jeroen Demeyer2019-07-021-63/+85
|
* bpo-37337: Add _PyObject_VectorcallMethod() (GH-14228)Jeroen Demeyer2019-06-281-0/+32
|
* bpo-36974: inherit tp_vectorcall_offset unconditionally (GH-13858)Jeroen Demeyer2019-06-241-1/+1
|
* bpo-37151: remove _PyCFunction_FastCallDict (GH-14269)Jeroen Demeyer2019-06-201-18/+0
|
* bpo-37151: remove _PyFunction_FastCallDict (GH-13864)Jeroen Demeyer2019-06-181-88/+0
|
* bpo-37194: Add a new public PyObject_CallNoArgs() function (GH-13890)Victor Stinner2019-06-171-0/+8
| | | | | | | | | | | | | | | Add a new public PyObject_CallNoArgs() function to the C API: call a callable Python object without any arguments. It is the most efficient way to call a callback without any argument. On x86-64, for example, PyObject_CallFunctionObjArgs(func, NULL) allocates 960 bytes on the stack per call, whereas PyObject_CallNoArgs(func) only allocates 624 bytes per call. It is excluded from stable ABI 3.8. Replace private _PyObject_CallNoArg() with public PyObject_CallNoArgs() in C extensions: _asyncio, _datetime, _elementtree, _pickle, _tkinter and readline.
* bpo-37231: remove _PyObject_FastCall_Prepend (GH-14153)Jeroen Demeyer2019-06-171-36/+0
|
* bpo-37249: add declaration of _PyObject_GetMethod (GH-14015)Jeroen Demeyer2019-06-141-3/+0
|
* bpo-36974: Make tp_call=PyVectorcall_Call work for inherited types (GH-13699)Petr Viktorin2019-06-021-1/+11
| | | | | | | | | | | | | | | | | | When inheriting a heap subclass from a vectorcall class that sets `.tp_call=PyVectorcall_Call` (as recommended in PEP 590), the subclass does not inherit `_Py_TPFLAGS_HAVE_VECTORCALL`, and thus `PyVectorcall_Call` does not work for it. This attempts to solve the issue by: * always inheriting `tp_vectorcall_offset` unless `tp_call` is overridden in the subclass * inheriting _Py_TPFLAGS_HAVE_VECTORCALL for static types, unless `tp_call` is overridden * making `PyVectorcall_Call` ignore `_Py_TPFLAGS_HAVE_VECTORCALL` This means it'll be ever more important to only call `PyVectorcall_Call` on classes that support vectorcall. In `PyVectorcall_Call`'s intended role as `tp_call` filler, that's not a problem.
* bpo-37122: Make co->co_argcount represent the total number of positonal ↵Pablo Galindo2019-06-011-4/+4
| | | | arguments in the code object (GH-13726)
* bpo-36974: rename _FastCallKeywords -> _Vectorcall (GH-13653)Jeroen Demeyer2019-05-301-5/+5
|
* bpo-36974: remove _PyObject_HasFastCall (GH-13460)Jeroen Demeyer2019-05-301-16/+0
|
* bpo-36974: implement PEP 590 (GH-13185)Jeroen Demeyer2019-05-291-103/+105
| | | | | Co-authored-by: Jeroen Demeyer <J.Demeyer@UGent.be> Co-authored-by: Mark Shannon <mark@hotpy.org>
* bpo-37017: PyObject_CallMethodObjArgs uses LOAD_METHOD optimization (GH-13516)Michael J. Sullivan2019-05-261-16/+29
| | | | | | | | | Update PyObject_CallMethodObjArgs and _PyObject_CallMethodIdObjArgs to use _PyObject_GetMethod to avoid creating a bound method object in many cases. On a microbenchmark of PyObject_CallMethodObjArgs calling a method on an interpreted Python class, this optimization resulted in a 1.7x speedup.
* bpo-36907: fix refcount bug in _PyStack_UnpackDict() (GH-13381)Jeroen Demeyer2019-05-221-5/+12
|
* Fix typo in _PyMethodDef_RawFastCallKeywords error message (GH-13343)Jeroen Demeyer2019-05-171-1/+1
|
* bpo-36540: PEP 570 -- Implementation (GH-12701)Pablo Galindo2019-04-291-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This commit contains the implementation of PEP570: Python positional-only parameters. * Update Grammar/Grammar with new typedarglist and varargslist * Regenerate grammar files * Update and regenerate AST related files * Update code object * Update marshal.c * Update compiler and symtable * Regenerate importlib files * Update callable objects * Implement positional-only args logic in ceval.c * Regenerate frozen data * Update standard library to account for positional-only args * Add test file for positional-only args * Update other test files to account for positional-only args * Add News entry * Update inspect module and related tests
* bpo-36030: Remove _PyStack_AsTuple() and _PyStack_AsTupleSlice() (GH-12032)Sergey Fedoseev2019-02-251-25/+4
|
* bpo-36030: Add _PyTuple_FromArray() function (GH-11954)Sergey Fedoseev2019-02-251-28/+2
|
* bpo-33012: Fix invalid function cast warnings with gcc 8. (GH-6749)Serhiy Storchaka2018-11-271-7/+7
| | | | | | Fix invalid function cast warnings with gcc 8 for method conventions different from METH_NOARGS, METH_O and METH_VARARGS excluding Argument Clinic generated code.
* bpo-35081: Add Include/internal/pycore_tupleobject.h (GH-10705)Victor Stinner2018-11-251-0/+1
| | | | Move _PyTuple_ITEMS() to a new header file: Include/internal/pycore_tupleobject.h
* bpo-35081: Add Include/internal/pycore_object.h (GH-10640)Victor Stinner2018-11-211-0/+1
| | | | Move _PyObject_GC_TRACK() and _PyObject_GC_UNTRACK() from Include/objimpl.h to Include/internal/pycore_object.h.
* bpo-35081: Rename internal headers (GH-10275)Victor Stinner2018-11-121-1/+1
| | | | | | | | | | | | | | Rename Include/internal/ headers: * pycore_hash.h -> pycore_pyhash.h * pycore_lifecycle.h -> pycore_pylifecycle.h * pycore_mem.h -> pycore_pymem.h * pycore_state.h -> pycore_pystate.h Add missing headers to Makefile.pre.in and PCbuild: * pycore_condvar.h. * pycore_hamt.h * pycore_pyhash.h
* bpo-35199: Add an internal _PyTuple_ITEMS() macro (GH-10434)Victor Stinner2018-11-091-11/+11
| | | | | | | * _PyTuple_ITEMS() gives access to the tuple->ob_item field and cast the first argument to PyTupleObject*. This internal macro is only usable if Py_BUILD_CORE is defined. * Replace &PyTuple_GET_ITEM(ob, 0) with _PyTuple_ITEMS(ob). * Replace PyTuple_GET_ITEM(op, 1) with &_PyTuple_ITEMS(ob)[1].
* bpo-35081: Add _PyThreadState_GET() internal macro (GH-10266)Victor Stinner2018-11-011-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | If Py_BUILD_CORE is defined, the PyThreadState_GET() macro access _PyRuntime which comes from the internal pycore_state.h header. Public headers must not require internal headers. Move PyThreadState_GET() and _PyInterpreterState_GET_UNSAFE() from Include/pystate.h to Include/internal/pycore_state.h, and rename PyThreadState_GET() to _PyThreadState_GET() there. The PyThreadState_GET() macro of pystate.h is now redefined when pycore_state.h is included, to use the fast _PyThreadState_GET(). Changes: * Add _PyThreadState_GET() macro * Replace "PyThreadState_GET()->interp" with _PyInterpreterState_GET_UNSAFE() * Replace PyThreadState_GET() with _PyThreadState_GET() in internal C files (compiled with Py_BUILD_CORE defined), but keep PyThreadState_GET() in the public header files. * _testcapimodule.c: replace PyThreadState_GET() with PyThreadState_Get(); the module is not compiled with Py_BUILD_CORE defined. * pycore_state.h now requires Py_BUILD_CORE to be defined.
* bpo-35081: Add pycore_ prefix to internal header files (GH-10263)Victor Stinner2018-10-311-1/+1
| | | | | | | | | | | | | | | | | | | | * Rename Include/internal/ header files: * pyatomic.h -> pycore_atomic.h * ceval.h -> pycore_ceval.h * condvar.h -> pycore_condvar.h * context.h -> pycore_context.h * pygetopt.h -> pycore_getopt.h * gil.h -> pycore_gil.h * hamt.h -> pycore_hamt.h * hash.h -> pycore_hash.h * mem.h -> pycore_mem.h * pystate.h -> pycore_state.h * warnings.h -> pycore_warnings.h * PCbuild project, Makefile.pre.in, Modules/Setup: add the Include/internal/ directory to the search paths of header files. * Update includes. For example, replace #include "internal/mem.h" with #include "pycore_mem.h".
* Fix issue 34551 - remove redundant store (#9009)Eric Lippert2018-10-221-1/+1
| | | The assignment of i/2 to nk is redundant because on this code path, nk is already the size of the dictionary, and i is already twice the size of the dictionary. I've replaced the store with an assertion that i/2 is nk.
* bpo-33720: Refactor marshalling/unmarshalling floats. (GH-8071)Serhiy Storchaka2018-07-241-1/+1
|
* bpo-32240: Add the const qualifier to declarations of PyObject* array ↵Serhiy Storchaka2017-12-151-21/+25
| | | | arguments. (#4746)
* bpo-31835: Optimize also FASTCALL using __future__ (#4087)Victor Stinner2017-10-251-2/+2
| | | | | _PyFunction_FastCallDict() and _PyFunction_FastCallKeywords() now also takes the fast path if the code object uses __future__ (CO_FUTURE_xxx flags).
* bpo-30860: Consolidate stateful runtime globals. (#3397)Eric Snow2017-09-081-0/+1
| | | | | | | * group the (stateful) runtime globals into various topical structs * consolidate the topical structs under a single top-level _PyRuntimeState struct * add a check-c-globals.py script that helps identify runtime globals Other globals are excluded (see globals.txt and check-c-globals.py).
* bpo-31347: _PyObject_FastCall_Prepend: do not call memcpy if args might not ↵Benjamin Peterson2017-09-051-3/+3
| | | | | be null (#3329) Passing NULL as the second argument to to memcpy is undefined behavior even if the size is 0.
* bpo-30923: Silence fall-through warnings included in -Wextra since gcc-7.0. ↵Stefan Krah2017-08-211-2/+2
| | | | (#3157)
* bpo-30640: Fix undefined behavior in _PyFunction_FastCallDict() and ↵Zackery Spytz2017-07-311-1/+1
| | | | | PyEval_EvalCodeEx() (#2919) k + 1 was calculated with k = NULL.
* bpo-29464: Rename METH_FASTCALL to METH_FASTCALL|METH_KEYWORDS and make (#1955)Serhiy Storchaka2017-07-031-2/+19
| | | | | the bare METH_FASTCALL be used for functions with positional-only parameters.
* bpo-30534: Fixed error messages when pass keyword arguments (#1901)Serhiy Storchaka2017-06-061-24/+25
| | | | | | | to functions implemented in C that don't support this. Also unified error messages for functions that don't take positional or keyword arguments.