aboutsummaryrefslogtreecommitdiff
Commit message (Collapse)AuthorAgeFilesLines
* Use static inline function Py_EnterRecursiveCall() (#91988)Victor Stinner2022-05-041-4/+4
| | | | | | | | | | | | | | | | Currently, calling Py_EnterRecursiveCall() and Py_LeaveRecursiveCall() may use a function call or a static inline function call, depending if the internal pycore_ceval.h header file is included or not. Use a different name for the static inline function to ensure that the static inline function is always used in Python internals for best performance. Similar approach than PyThreadState_GET() (function call) and _PyThreadState_GET() (static inline function). * Rename _Py_EnterRecursiveCall() to _Py_EnterRecursiveCallTstate() * Rename _Py_LeaveRecursiveCall() to _Py_LeaveRecursiveCallTstate() * pycore_ceval.h: Rename Py_EnterRecursiveCall() to _Py_EnterRecursiveCall() and Py_LeaveRecursiveCall() and _Py_LeaveRecursiveCall()
* bpo-47162: Add call trampoline to mitigate bad fpcasts on Emscripten (GH-32189)Christian Heimes2022-03-301-1/+2
|
* bpo-46845: Reduce dict size when all keys are Unicode (GH-31564)Inada Naoki2022-03-021-17/+2
|
* bpo-45459: C API uses type names rather than structure names (GH-31528)Victor Stinner2022-02-241-2/+1
| | | | Thanks to the new pytypedefs.h, it becomes to use type names like PyObject rather like structure names like "struct _object".
* bpo-46541: Replace core use of _Py_IDENTIFIER() with statically initialized ↵Eric Snow2022-02-081-1/+35
| | | | | | | | | | | | | | | | | | | | | | | | | | | | global objects. (gh-30928) We're no longer using _Py_IDENTIFIER() (or _Py_static_string()) in any core CPython code. It is still used in a number of non-builtin stdlib modules. The replacement is: PyUnicodeObject (not pointer) fields under _PyRuntimeState, statically initialized as part of _PyRuntime. A new _Py_GET_GLOBAL_IDENTIFIER() macro facilitates lookup of the fields (along with _Py_GET_GLOBAL_STRING() for non-identifier strings). https://bugs.python.org/issue46541#msg411799 explains the rationale for this change. The core of the change is in: * (new) Include/internal/pycore_global_strings.h - the declarations for the global strings, along with the macros * Include/internal/pycore_runtime_init.h - added the static initializers for the global strings * Include/internal/pycore_global_objects.h - where the struct in pycore_global_strings.h is hooked into _PyRuntimeState * Tools/scripts/generate_global_objects.py - added generation of the global string declarations and static initializers I've also added a --check flag to generate_global_objects.py (along with make check-global-objects) to check for unused global strings. That check is added to the PR CI config. The remainder of this change updates the core code to use _Py_GET_GLOBAL_IDENTIFIER() instead of _Py_IDENTIFIER() and the related _Py*Id functions (likewise for _Py_GET_GLOBAL_STRING() instead of _Py_static_string()). This includes adding a few functions where there wasn't already an alternative to _Py*Id(), replacing the _Py_Identifier * parameter with PyObject *. The following are not changed (yet): * stop using _Py_IDENTIFIER() in the stdlib modules * (maybe) get rid of _Py_IDENTIFIER(), etc. entirely -- this may not be doable as at least one package on PyPI using this (private) API * (maybe) intern the strings during runtime init https://bugs.python.org/issue46541
* bpo-44525: Copy free variables in bytecode to allow calls to inner functions ↵Mark Shannon2021-11-231-3/+3
| | | | | | | | | | | to be specialized (GH-29595) * Make internal APIs that take PyFrameConstructor take a PyFunctionObject instead. * Add reference to function to frame, borrow references to builtins and globals. * Add COPY_FREE_VARS instruction to allow specialization of calls to inner functions.
* bpo-45439: Move _PyObject_VectorcallTstate() to pycore_call.h (GH-28893)Victor Stinner2021-10-141-5/+42
| | | | | | | | | | | * Move _PyObject_VectorcallTstate() and _PyObject_FastCallTstate() to pycore_call.h (internal C API). * Convert PyObject_CallOneArg(), PyObject_Vectorcall(), _PyObject_FastCall() and PyVectorcall_Function() static inline functions to regular functions. * Add _PyVectorcall_FunctionInline() static inline function. * PyObject_Vectorcall(), _PyObject_FastCall(), and PyObject_CallOneArg() now call _PyThreadState_GET() rather than PyThreadState_Get().
* bpo-45439: Rename _PyObject_CallNoArg() to _PyObject_CallNoArgs() (GH-28891)Victor Stinner2021-10-121-4/+4
| | | | | Fix typo in the private _PyObject_CallNoArg() function name: rename it to _PyObject_CallNoArgs() to be consistent with the public function PyObject_CallNoArgs().
* bpo-45439: _PyObject_Call() only checks tp_vectorcall_offset once (GH-28890)Victor Stinner2021-10-121-23/+36
| | | | | | Add _PyVectorcall_Call() helper function. Add "assert(PyCallable_Check(callable));" to PyVectorcall_Call(), similar check than PyVectorcall_Function().
* bpo-42990: Further refactoring of PyEval_ functions. (GH-24368)Mark Shannon2021-02-011-70/+7
| | | | | | | | | | * Further refactoring of PyEval_EvalCode and friends. Break into make-frame, and eval-frame parts. * Simplify function vector call using new _PyEval_Vector. * Remove unused internal functions: _PyEval_EvalCodeWithName and _PyEval_EvalCode. * Don't use legacy function PyEval_EvalCodeEx.
* bpo-42990: Introduce 'frame constructor' struct to simplify API for ↵Mark Shannon2021-01-291-26/+7
| | | | | | | PyEval_CodeEval and friends (GH-24298) * Introduce 'frame constructor' to simplify API for frame creation * Embed struct using a macro to conform to PEP 7
* bpo-42979: Enhance abstract.c assertions checking slot result (GH-24352)Victor Stinner2021-01-271-6/+30
| | | | | | | | * bpo-42979: Enhance abstract.c assertions checking slot result Add _Py_CheckSlotResult() function which fails with a fatal error if a slot function succeeded with an exception set or failed with no exception set: write the slot name, the type name and the current exception (if an exception is set).
* bpo-40052: Fix alignment issue in PyVectorcall_Function() (GH-23999)Petr Viktorin2020-12-291-1/+2
| | | | | | | | | | | | | | | ``` In file included from /usr/include/python3.8/Python.h:147: In file included from /usr/include/python3.8/abstract.h:837: /usr/include/python3.8/cpython/abstract.h:91:11: error: cast from 'char *' to 'vectorcallfunc *' (aka 'struct _object *(**)(struct _object *, struct _object *const *, unsigned long, struct _object *)') increases required alignment from 1 to 8 [-Werror,-Wcast-align] ptr = (vectorcallfunc*)(((char *)callable) + offset); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1 error generated. ``` Co-Authored-By: Andreas Schneider <asn@cryptomilk.org> Co-Authored-By: Antoine Pitrou <antoine@python.org>
* bpo-41078: Rename pycore_tupleobject.h to pycore_tuple.h (GH-21056)Victor Stinner2020-06-221-7/+7
|
* bpo-40268: Remove a few pycore_pystate.h includes (GH-19510)Victor Stinner2020-04-141-2/+2
|
* bpo-39882: Add _Py_FatalErrorFormat() function (GH-19157)Victor Stinner2020-03-251-2/+4
|
* 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-051-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-121-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-211-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.