summaryrefslogtreecommitdiffstats
path: root/Include/cpython
Commit message (Collapse)AuthorAgeFilesLines
* gh-104584: Baby steps towards generating and executing traces (#105924)Guido van Rossum2023-06-271-0/+1
| | | | | Added a new, experimental, tracing optimizer and interpreter (a.k.a. "tier 2"). This currently pessimizes, so don't use yet -- this is infrastructure so we can experiment with optimizing passes. To enable it, pass ``-Xuops`` or set ``PYTHONUOPS=1``. To get debug output, set ``PYTHONUOPSDEBUG=N`` where ``N`` is a debug level (0-4, where 0 is no debug output and 4 is excessively verbose). All of this code is likely to change dramatically before the 3.13 feature freeze. But this is a first step.
* gh-106084: Remove _PyObject_RealIsInstance() function (#106106)Victor Stinner2023-06-261-12/+4
| | | | | | | | | | | | | | | Remove the following functions from the public C API: * _PyObject_RealIsInstance() * _PyObject_RealIsSubclass() * _Py_add_one_to_index_F() * _Py_add_one_to_index_C() Move _PyObject_RealIsInstance() and _PyObject_RealIsSubclass() to the internal C API (pycore_abstract.h) and no longer export their symbols (in libpython). Make _Py_add_one_to_index_F() and _Py_add_one_to_index_C() functions static: no longer export them.
* gh-106084: Remove _PyObject_HasLen() function (#106103)Victor Stinner2023-06-261-20/+0
| | | | | | | | | Remove _PyObject_HasLen() and _PySequence_IterSearch() functions from the public C API: move them to the internal C API (pycore_abstract.h). No longer export these symbols (in libpython). Remove also unused pycore_initconfig.h include in typeobject.c.
* gh-105927: Deprecate PyWeakref_GetObject() function (#106006)Victor Stinner2023-06-261-1/+2
| | | Deprecate PyWeakref_GetObject() and PyWeakref_GET_OBJECT() functions.
* gh-106084: Remove _PySequence_BytesToCharpArray() function (#106088)Victor Stinner2023-06-261-4/+0
| | | | | Remove private _PySequence_BytesToCharpArray() and _Py_FreeCharPArray() functions from the public C API: move these functions from Objects/abstract.c to Modules/_posixsubprocess.c.
* gh-106084: Remove old PyObject call aliases (#106085)Victor Stinner2023-06-261-9/+0
| | | | | | | | | | | | | | Remove old aliases which were kept backwards compatibility with Python 3.8: * _PyObject_CallMethodNoArgs() * _PyObject_CallMethodOneArg() * _PyObject_CallOneArg() * _PyObject_FastCallDict() * _PyObject_Vectorcall() * _PyObject_VectorcallMethod() * _PyVectorcall_Function() Update code which used these aliases to use new names.
* gh-105927: Remove _PyWeakref_GetWeakrefCount() (#106007)Victor Stinner2023-06-231-4/+0
| | | | | | Remove _PyWeakref_GetWeakrefCount() and _PyWeakref_ClearRef() from the public C API: move them to the internal C API. Refactor also _weakref_getweakrefs() code to make it more readable.
* GH-91095: Specialize calls to normal Python classes. (GH-99331)Mark Shannon2023-06-221-0/+1
|
* gh-104812: Run Pending Calls in any Thread (gh-104813)Eric Snow2023-06-131-0/+2
| | | For a while now, pending calls only run in the main thread (in the main interpreter). This PR changes things to allow any thread run a pending call, unless the pending call was explicitly added for the main thread to run.
* gh-105603: Change the PyInterpreterConfig.own gil Field (gh-105620)Eric Snow2023-06-131-3/+7
| | | We are changing it to be more flexible that a strict bool can be for possible future expanded used cases.
* gh-105268: Remove _PyGC_FINALIZED() macro (#105350)Victor Stinner2023-06-061-8/+0
| | | | | Remove the old private, undocumented and untested _PyGC_FINALIZED() macro which was kept for backward compatibility with Python 3.8 and older.
* GH-104584: Allow optimizers to opt out of optimizing. (GH-105244)Mark Shannon2023-06-051-1/+2
|
* gh-101524: Only Use Public C-API in the _xxsubinterpreters Module (gh-105258)Eric Snow2023-06-021-0/+11
| | | The _xxsubinterpreters module was meant to only use public API. Some internal C-API usage snuck in over the last few years (e.g. gh-28969). This fixes that.
* GH-104584: Plugin optimizer API (GH-105100)Mark Shannon2023-06-022-0/+62
|
* gh-105156: Cleanup usage of old Py_UNICODE type (#105158)Victor Stinner2023-06-011-5/+3
| | | | | | | | | | | | * refcounts.dat: * Remove Py_UNICODE functions. * Replace Py_UNICODE argument type with wchar_t. * _PyUnicode_ToLowercase(), _PyUnicode_ToUppercase(), _PyUnicode_ToTitlecase() are no longer deprecated in comments. It's no longer needed since they now use Py_UCS4 type, rather than the deprecated Py_UNICODE type. * gdb: Remove unused char_width() method.
* gh-105145: Remove old functions to config Python init (#105154)Victor Stinner2023-06-011-9/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Remove the following old functions to configure the Python initialization, deprecated in Python 3.11: * PySys_AddWarnOptionUnicode() * PySys_AddWarnOption() * PySys_AddXOption() * PySys_HasWarnOptions() * PySys_SetArgvEx() * PySys_SetArgv() * PySys_SetPath() * Py_SetPath() * Py_SetProgramName() * Py_SetPythonHome() * Py_SetStandardStreamEncoding() * _Py_SetProgramFullPath() Most of these functions are kept in the stable ABI, except: * Py_SetStandardStreamEncoding() * _Py_SetProgramFullPath() Update Doc/extending/embedding.rst and Doc/extending/extending.rst to use the new PyConfig API. _testembed.c: * check_stdio_details() now sets stdio_encoding and stdio_errors of PyConfig. * Add definitions of functions removed from the API but kept in the stable ABI. * test_init_from_config() and test_init_read_set() now use PyConfig_SetString() instead of PyConfig_SetBytesString(). Remove _Py_ClearStandardStreamEncoding() internal function.
* gh-105156: Deprecate the old Py_UNICODE type in C API (#105157)Victor Stinner2023-06-011-2/+2
| | | | | | | | Deprecate the old Py_UNICODE and PY_UNICODE_TYPE types in the C API: use wchar_t instead. Replace Py_UNICODE with wchar_t in multiple C files. Co-authored-by: Inada Naoki <songofacandy@gmail.com>
* gh-105111: remove deprecated macros Py_TRASHCAN_SAFE_BEGIN and ↵Irit Katriel2023-05-311-13/+0
| | | | Py_TRASHCAN_SAFE_END (#105112)
* gh-104922: Make `PY_SSIZE_T_CLEAN` not mandatory again (#105051)Inada Naoki2023-05-312-30/+0
|
* gh-105071: add PyUnstable_Exc_PrepReraiseStar to expose except* ↵Irit Katriel2023-05-301-0/+4
| | | | implementation in the unstable API (#105072)
* GH-101291: Avoid using macros with casts in low-level long API. (#104742)Mark Shannon2023-05-221-2/+3
|
* GH-101291: Add low level, unstable API for pylong (GH-101685)Mark Shannon2023-05-212-0/+31
| | | Co-authored-by: Petr Viktorin <encukou@gmail.com>
* GH-96803: Document and test new unstable internal frame API functions ↵Mark Shannon2023-05-181-1/+1
| | | | | | (GH-104211) Weaken contract of PyUnstable_InterpreterFrame_GetCode to return PyObject*.
* gh-103763: Implement PEP 695 (#103764)Jelle Zijlstra2023-05-161-0/+1
| | | | | | | | | | | | | | This implements PEP 695, Type Parameter Syntax. It adds support for: - Generic functions (def func[T](): ...) - Generic classes (class X[T](): ...) - Type aliases (type X = ...) - New scoping when the new syntax is used within a class body - Compiler and interpreter changes to support the new syntax and scoping rules Co-authored-by: Marc Mueller <30130371+cdce8p@users.noreply.github.com> Co-authored-by: Eric Traut <eric@traut.com> Co-authored-by: Larry Hastings <larry@hastings.org> Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
* gh-104341: Adjust tstate_must_exit() to Respect Interpreter Finalization ↵Eric Snow2023-05-151-0/+1
| | | | | (gh-104437) With the move to a per-interpreter GIL, this check slipped through the cracks.
* GH-102181: Improve specialization stats for SEND (GH-102182)penguin_wwy2023-05-101-0/+2
|
* gh-104223: Fix issues with inheriting from buffer classes (#104227)Jelle Zijlstra2023-05-081-0/+1
| | | Co-authored-by: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com>
* gh-99113: Add PyInterpreterConfig.own_gil (gh-104204)Eric Snow2023-05-051-0/+3
| | | | | We also add PyInterpreterState.ceval.own_gil to record if the interpreter actually has its own GIL. Note that for now we don't actually respect own_gil; all interpreters still share the one GIL. However, PyInterpreterState.ceval.own_gil does reflect PyInterpreterConfig.own_gil. That lie is a temporary one that we will fix when the GIL really becomes per-interpreter.
* GH-96803: Add three C-API functions to make _PyInterpreterFrame less opaque ↵Mark Shannon2023-05-051-0/+17
| | | | for users of PEP 523. (GH-96849)
* gh-103509: PEP 697 -- Limited C API for Extending Opaque Types (GH-103511)Petr Viktorin2023-05-041-0/+1
| | | | Co-authored-by: Oleg Iarygin <oleg@arhadthedev.net> Co-authored-by: Erlend E. Aasland <erlend.aasland@protonmail.com>
* gh-104109: Expose Py_NewInterpreterFromConfig() in the Public C-API (gh-104110)Eric Snow2023-05-032-3/+3
| | | | | We also expose PyInterpreterConfig. This is part of the PEP 684 (per-interpreter GIL) implementation. We will add docs as soon as we can. FYI, I'm adding the new config field for per-interpreter GIL in gh-99114.
* gh-103743: Add PyUnstable_Object_GC_NewWithExtraData (GH-103744)Jurica Bradarić2023-05-021-0/+3
| | | | Co-authored-by: Petr Viktorin <encukou@gmail.com> Co-authored-by: Erlend E. Aasland <erlend.aasland@protonmail.com>
* gh-101659: Isolate "obmalloc" State to Each Interpreter (gh-101660)Eric Snow2023-04-242-0/+8
| | | | | | | | | | | | | | This is strictly about moving the "obmalloc" runtime state from `_PyRuntimeState` to `PyInterpreterState`. Doing so improves isolation between interpreters, specifically most of the memory (incl. objects) allocated for each interpreter's use. This is important for a per-interpreter GIL, but such isolation is valuable even without it. FWIW, a per-interpreter obmalloc is the proverbial canary-in-the-coalmine when it comes to the isolation of objects between interpreters. Any object that leaks (unintentionally) to another interpreter is highly likely to cause a crash (on debug builds at least). That's a useful thing to know, relative to interpreter isolation.
* gh-103091: Add PyUnstable_Type_AssignVersionTag (#103095)Brett Simmers2023-04-241-0/+7
|
* gh-84436: Implement Immortal Objects (gh-19474)Eddie Elizondo2023-04-221-4/+13
| | | | | | | | | This is the implementation of PEP683 Motivation: The PR introduces the ability to immortalize instances in CPython which bypasses reference counting. Tagging objects as immortal allows up to skip certain operations when we know that the object will be around for the entire execution of the runtime. Note that this by itself will bring a performance regression to the runtime due to the extra reference count checks. However, this brings the ability of having truly immutable objects that are useful in other contexts such as immutable data sharing between sub-interpreters.
* GH-103082: Implementation of PEP 669: Low Impact Monitoring for CPython ↵Mark Shannon2023-04-122-12/+44
| | | | | | | | | | (GH-103083) * The majority of the monitoring code is in instrumentation.c * The new instrumentation bytecodes are in bytecodes.c * legacy_tracing.c adapts the new API to the old sys.setrace and sys.setprofile APIs
* gh-101659: Add _Py_AtExit() (gh-103298)Eric Snow2023-04-061-0/+4
| | | | | The function is like Py_AtExit() but for a single interpreter. This is a companion to the atexit module's register() function, taking a C callback instead of a Python one. We also update the _xxinterpchannels module to use _Py_AtExit(), which is the motivating case. (This is inspired by pain points felt while working on gh-101660.)
* gh-102192: deprecate _PyErr_ChainExceptions (#102935)Irit Katriel2023-04-011-1/+1
|
* GH-89987: Shrink the BINARY_SUBSCR caches (GH-103022)Brandt Bucher2023-03-291-0/+11
|
* GH-101291: Rearrange the size bits in PyLongObject (GH-102464)Mark Shannon2023-03-221-1/+5
| | | | | | | | | | * Eliminate all remaining uses of Py_SIZE and Py_SET_SIZE on PyLongObject, adding asserts. * Change layout of size/sign bits in longobject to support future addition of immortal ints and tagged medium ints. * Add functions to hide some internals of long object, and for setting sign and digit count. * Replace uses of IS_MEDIUM_VALUE macro with _PyLong_IsCompact().
* gh-102406: replace exception chaining by PEP-678 notes in codecs (#102407)Irit Katriel2023-03-211-18/+0
|
* gh-102304: Move the Total Refcount to PyInterpreterState (gh-102545)Eric Snow2023-03-211-0/+1
| | | | | Moving it valuable with a per-interpreter GIL. However, it is also useful without one, since it allows us to identify refleaks within a single interpreter or where references are escaping an interpreter. This becomes more important as we move the obmalloc state to PyInterpreterState. https://github.com/python/cpython/issues/102304
* gh-98608: Stop Treating All Errors from _Py_NewInterpreterFromConfig() as ↵Eric Snow2023-03-212-2/+4
| | | | | | | Fatal (gh-102657) Prior to this change, errors in _Py_NewInterpreterFromConfig() were always fatal. Instead, callers should be able to handle such errors and keep going. That's what this change supports. (This was an oversight in the original implementation of _Py_NewInterpreterFromConfig().) Note that the existing [fatal] behavior of the public Py_NewInterpreter() is preserved. https://github.com/python/cpython/issues/98608
* gh-102304: Move _Py_RefTotal to _PyRuntimeState (gh-102543)Eric Snow2023-03-201-1/+4
| | | | | | | The essentially eliminates the global variable, with the associated benefits. This is also a precursor to isolating this bit of state to PyInterpreterState. Folks that currently read _Py_RefTotal directly would have to start using _Py_GetGlobalRefTotal() instead. https://github.com/python/cpython/issues/102304
* gh-102594: PyErr_SetObject adds note to exception raised on normalization ↵Irit Katriel2023-03-161-0/+4
| | | | error (#102675)
* gh-100227: Isolate the Import State to Each Interpreter (gh-101941)Eric Snow2023-03-091-2/+2
| | | | | | | | | | | | Specific changes: * move the import lock to PyInterpreterState * move the "find_and_load" diagnostic state to PyInterpreterState Note that the import lock exists to keep multiple imports of the same module in the same interpreter (but in different threads) from stomping on each other. Independently, we use a distinct global lock to protect globally shared import state, especially related to loaded extension modules. For now we can rely on the GIL as that lock but with a per-interpreter GIL we'll need a new global lock. The remaining state in _PyRuntimeState.imports will (probably) continue being global. https://github.com/python/cpython/issues/100227
* gh-102304: Consolidate Direct Usage of _Py_RefTotal (gh-102514)Eric Snow2023-03-081-0/+1
| | | | | This simplifies further changes to _Py_RefTotal (e.g. make it atomic or move it to PyInterpreterState). https://github.com/python/cpython/issues/102304
* gh-102381: don't call watcher callback with dead object (#102382)Carl Meyer2023-03-083-20/+30
| | | Co-authored-by: T. Wouters <thomas@python.org>
* gh-101101: Unstable C API tier (PEP 689) (GH-101102)Petr Viktorin2023-02-282-9/+45
|
* GH-100719: Remove redundant `gi_code` field from generator object. (GH-100749)Mark Shannon2023-02-231-3/+2
|