summaryrefslogtreecommitdiffstats
path: root/Include/cpython
Commit message (Collapse)AuthorAgeFilesLines
* bpo-45953: Statically allocate the main interpreter (and initial thread ↵Eric Snow2022-01-121-1/+9
| | | | | | | | | state). (gh-29883) Previously, the main interpreter was allocated on the heap during runtime initialization. Here we instead embed it into _PyRuntimeState, which means it is statically allocated as part of the _PyRuntime global. The same goes for the initial thread state (of each interpreter, including the main one). Consequently there are fewer allocations during runtime/interpreter init, fewer possible failures, and better memory locality. FYI, this also helps efforts to consolidate globals, which in turns helps work on subinterpreter isolation. https://bugs.python.org/issue45953
* bpo-46303: Move fileutils.h private functions to internal C API (GH-30484)Victor Stinner2022-01-111-159/+1
| | | | | | | | | | Move almost all private functions of Include/cpython/fileutils.h to the internal C API Include/internal/pycore_fileutils.h. Only keep _Py_fopen_obj() in Include/cpython/fileutils.h, since it's used by _testcapi which must not use the internal C API. Move EncodeLocaleEx() and DecodeLocaleEx() functions from _testcapi to _testinternalcapi, since the C API moved to the internal C API.
* bpo-46218: Change long_pow() to sliding window algorithm (GH-30319)Tim Peters2022-01-021-6/+0
| | | | | | | | | | | * bpo-46218: Change long_pow() to sliding window algorithm The primary motivation is to eliminate long_pow's reliance on that the number of bits in a long "digit" is a multiple of 5. Now it no longer cares how many bits are in a digit. But the sliding window approach also allows cutting the precomputed table of small powers in half, which reduces initialization overhead enough that the approach pays off for smaller exponents too. Depending on exponent bit patterns, a sliding window may also be able to save some bigint multiplies (sometimes when at least 5 consecutive exponent bits are 0, regardless of their starting bit position modulo 5). Note: boosting the window width to 6 didn't work well overall. It give marginal speed improvements for huge exponents, but the increased overhead (the small-power table needs twice as many entries) made it a loss for smaller exponents. Co-authored-by: Oleg Iarygin <dralife@yandex.ru>
* bpo-46140: take more Py_buffer arguments as const * (GH-30217)David Hewitt2021-12-221-3/+3
|
* bpo-45711: Remove type and traceback from exc_info (GH-30122)Irit Katriel2021-12-171-1/+1
| | | | | | | | * Do not PUSH/POP traceback or type to the stack as part of exc_info * Remove exc_traceback and exc_type from _PyErr_StackItem * Add to what's new, because this change breaks things like Cython
* bpo-46007: Exclude PyUnicode_CHECK_INTERNED() from limited C API (GH-29987)Victor Stinner2021-12-091-0/+4
| | | | | | | Exclude the PyUnicode_CHECK_INTERNED() macro from the limited C API, because it uses the PyASCIIObject structure which is excluded from the limited C API. Automerge-Triggered-By: GH:encukou
* bpo-46008: Move Py*State init into distinct functions. (gh-29977)Eric Snow2021-12-081-0/+6
| | | | | Previously, basic initialization of PyInterprterState happened in PyInterpreterState_New() (along with allocation and adding the new interpreter to the runtime state). This prevented us from initializing interpreter states that were allocated separately (e.g. statically or in a free list). We've addressed that here by factoring out a separate function just for initialization. We've done the same for PyThreadState. _PyRuntimeState was sorted out when we added it since _PyRuntime is statically allocated. However, here we update the existing init code to line up with the functions for PyInterpreterState and PyThreadState. https://bugs.python.org/issue46008
* bpo-45947: Place dict and values pointer at fixed (negative) offset just ↵Mark Shannon2021-12-072-4/+0
| | | | | | | | | | | | | | | | | | | before GC header. (GH-29879) * Place __dict__ immediately before GC header for plain Python objects. * Fix up lazy dict creation logic to use managed dict pointers. * Manage values pointer, placing them directly before managed dict pointers. * Convert hint-based load/store attr specialization target managed dict classes. * Specialize LOAD_METHOD for managed dict objects. * Remove unsafe _PyObject_GC_Calloc function. * Remove unsafe _PyObject_GC_Malloc() function. * Add comment explaning use of Py_TPFLAGS_MANAGED_DICT.
* bpo-45963: Make space for the InterpreterFrame of a generator in that ↵Mark Shannon2021-12-061-15/+8
| | | | | | | generator. (GH-29891) * Make generator, coroutine and async gen structs all the same size. * Store interpreter frame in generator (and coroutine). Reduces the number of allocations neeeded for a generator from two to one.
* bpo-45607: Make it possible to enrich exception displays via setting their ↵Irit Katriel2021-12-031-1/+1
| | | | __note__ field (GH-29880)
* bpo-45885: Specialize COMPARE_OP (GH-29734)Dennis Sweeney2021-12-031-0/+3
| | | | | | | * Add COMPARE_OP_ADAPTIVE adaptive instruction. * Add COMPARE_OP_FLOAT_JUMP, COMPARE_OP_INT_JUMP and COMPARE_OP_STR_JUMP specialized instructions. * Introduce and use _PyUnicode_Equal
* bpo-45582: Port getpath[p].c to Python (GH-29041)Steve Dower2021-12-032-6/+3
| | | | | The getpath.py file is frozen at build time and executed as code over a namespace. It is never imported, nor is it meant to be importable or reusable. However, it should be easier to read, modify, and patch than the previous code. This commit attempts to preserve every previously tested quirk, but these may be changed in the future to better align platforms.
* bpo-45954: Rename PyConfig.no_debug_ranges to code_debug_ranges (GH-29886)Victor Stinner2021-12-021-1/+1
| | | | | | | Rename PyConfig.no_debug_ranges to PyConfig.code_debug_ranges and invert the value. Document -X no_debug_ranges and PYTHONNODEBUGRANGES env var in PyConfig.code_debug_ranges documentation.
* bpo-45476: Add _Py_RVALUE() macro (GH-29860)Victor Stinner2021-11-303-3/+3
| | | | | | | | | | | | | | | | | | Add a new _Py_RVALUE() macro to prevent using an expression as an l-value. Replace a "(void)" cast with the _Py_RVALUE() macro in the following macros: * PyCell_SET() * PyList_SET_ITEM() * PyTuple_SET_ITEM() * _PyGCHead_SET_FINALIZED() * _PyGCHead_SET_NEXT() * asdl_seq_SET() * asdl_seq_SET_UNTYPED() Add also parentheses around macro arguments in PyCell_SET() and PyTuple_SET_ITEM() macros.
* bpo-45786: Allocate space for frame in frame object. (GH-29729)Mark Shannon2021-11-291-2/+4
|
* bpo-45893: Add missing extern C to initconfig.h (GH-29761)Christian Heimes2021-11-241-0/+6
| | | Co-authored-by: Steve Dower <steve.dower@python.org>
* bpo-39026: Fix Python.h when building with Xcode (GH-29488)Victor Stinner2021-11-231-2/+0
| | | | Fix Python.h to build C extensions with Xcode: remove a relative include from Include/cpython/pystate.h.
* bpo-44525: Copy free variables in bytecode to allow calls to inner functions ↵Mark Shannon2021-11-231-3/+0
| | | | | | | | | | | 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-45848: Allow the parser to get error lines from encoded files (GH-29646)Pablo Galindo Salgado2021-11-201-0/+5
|
* bpo-45753: Make recursion checks more efficient. (GH-29524)Mark Shannon2021-11-161-2/+2
| | | | * Uses recursion remaining, instead of recursion depth to speed up check against recursion limit.
* bpo-45696: Deep-freeze selected modules (GH-29118)Guido van Rossum2021-11-111-0/+1
| | | | | | | This gains 10% or more in startup time for `python -c pass` on UNIX-ish systems. The Makefile.pre.in generating code builds on Eric's work for bpo-45020, but the .c file generator is new. Windows version TBD.
* bpo-45637: Store the frame pointer in the cframe (GH-29267)Mark Shannon2021-10-281-2/+2
| | | * Rename 'frame' to 'current_frame'
* bpo-45292: [PEP 654] add the ExceptionGroup and BaseExceptionGroup classes ↵Irit Katriel2021-10-221-0/+6
| | | | (GH-28569)
* bpo-45315: PyType_FromSpec: Copy spec->name and have the type own the memory ↵Petr Viktorin2021-10-211-0/+1
| | | | for its name (GH-29103)
* bpo-35134: Add Include/cpython/longobject.h (GH-29044)Victor Stinner2021-10-191-0/+95
| | | | | | | | | | Move Include/longobject.h non-limited API to a new Include/cpython/longobject.h header file. Move the following definitions to the internal C API: * _PyLong_DigitValue * _PyLong_FormatAdvancedWriter() * _PyLong_FormatWriter()
* bpo-35134: Split warnings.h and weakrefobject.h (GH-29042)Victor Stinner2021-10-182-0/+67
| | | | | | | | | | | | | Split header files to move the non-limited API to Include/cpython/: * Include/warnings.h => Include/cpython/warnings.h * Include/weakrefobject.h => Include/cpython/weakrefobject.h Exclude PyWeakref_GET_OBJECT() from the limited C API. It never worked since the PyWeakReference structure is opaque in the limited C API. Move _PyWarnings_Init() and _PyErr_WarnUnawaitedCoroutine() to the internal C API.
* bpo-43760: Add PyThreadState_EnterTracing() (GH-28542)Victor Stinner2021-10-151-0/+7
| | | | | | | | | | Add PyThreadState_EnterTracing() and PyThreadState_LeaveTracing() functions to the limited C API to suspend and resume tracing and profiling. Add an unit test on the PyThreadState C API to _testcapi. Add also internal _PyThreadState_DisableTracing() and _PyThreadState_ResetTracing().
* bpo-45434: Remove Include/eval.h header file (GH-28973)Victor Stinner2021-10-151-0/+2
| | | | Move Include/eval.h content into Include/ceval.h and Include/cpython/ceval.h, and remove Include/eval.h.
* bpo-35081: Move interpreteridobject.h to Include/internal/ (GH-28969)Victor Stinner2021-10-151-11/+0
| | | | Move the interpreteridobject.h header file from Include/ to Include/internal/. It only provides private functions.
* bpo-35134: Move classobject.h to Include/cpython/ (GH-28968)Victor Stinner2021-10-154-0/+334
| | | | | | | | | Move classobject.h, context.h, genobject.h and longintrepr.h header files from Include/ to Include/cpython/. Remove redundant "#ifndef Py_LIMITED_API" in context.h. Remove explicit #include "longintrepr.h" in C files. It's not needed, Python.h already includes it.
* bpo-35134: Move Include/cellobject.h to Include/cpython/ (GH-28964)Victor Stinner2021-10-151-0/+31
|
* po-35134: Move Include/funcobject.h to Include/cpython/ (GH-28958)Victor Stinner2021-10-141-0/+118
| | | Remove redundant "#ifndef Py_LIMITED_API" in funcobject.h.
* bpo-35134: Add Include/cpython/floatobject.h (GH-28957)Victor Stinner2021-10-141-0/+12
| | | | | Split Include/floatobject.h into sub-files: add Include/cpython/floatobject.h and Include/internal/pycore_floatobject.h.
* bpo-45439: Move _PyObject_VectorcallTstate() to pycore_call.h (GH-28893)Victor Stinner2021-10-141-93/+12
| | | | | | | | | | | * 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-45467: Fix IncrementalDecoder and StreamReader in the ↵Serhiy Storchaka2021-10-141-0/+10
| | | | | | | | | "raw-unicode-escape" codec (GH-28944) They support now splitting escape sequences between input chunks. Add the third parameter "final" in codecs.raw_unicode_escape_decode(). It is True by default to match the former behavior.
* bpo-45461: Fix IncrementalDecoder and StreamReader in the "unicode-escape" ↵Serhiy Storchaka2021-10-141-1/+9
| | | | | | | | | codec (GH-28939) They support now splitting escape sequences between input chunks. Add the third parameter "final" in codecs.unicode_escape_decode(). It is True by default to match the former behavior.
* bpo-45340: Don't create object dictionaries unless actually needed (GH-28802)Mark Shannon2021-10-131-0/+1
| | | | | | | | | | | | | | * Never change types' cached keys. It could invalidate inline attribute objects. * Lazily create object dictionaries. * Update specialization of LOAD/STORE_ATTR. * Don't update shared keys version for deletion of value. * Update gdb support to handle instance values. * Rename SPLIT_KEYS opcodes to INSTANCE_VALUE.
* bpo-45434: Convert Py_GETENV() macro to a function (GH-28912)Victor Stinner2021-10-131-1/+1
| | | Avoid calling directly getenv() in the header file.
* bpo-45439: Move _PyObject_CallNoArgs() to pycore_call.h (GH-28895)Victor Stinner2021-10-121-9/+0
| | | | | | | * Move _PyObject_CallNoArgs() to pycore_call.h (internal C API). * _ssl, _sqlite and _testcapi extensions now call the public PyObject_CallNoArgs() function, rather than _PyObject_CallNoArgs(). * _lsprof extension is now built with Py_BUILD_CORE_MODULE macro defined to get access to internal _PyObject_CallNoArgs().
* bpo-45439: Rename _PyObject_CallNoArg() to _PyObject_CallNoArgs() (GH-28891)Victor Stinner2021-10-111-1/+1
| | | | | 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-111-0/+1
| | | | | | Add _PyVectorcall_Call() helper function. Add "assert(PyCallable_Check(callable));" to PyVectorcall_Call(), similar check than PyVectorcall_Function().
* bpo-41123: Remove Py_UNICODE_COPY() and Py_UNICODE_FILL() (GH-28887)Victor Stinner2021-10-111-13/+0
|
* Fix typos in the Include directory (GH-28745)Christian Clauss2021-10-063-4/+4
|
* bpo-40116: Add insertion order bit-vector to dict values to allow dicts to ↵Mark Shannon2021-10-061-1/+2
| | | | share keys more freely. (GH-28520)
* bpo-41710: Add private _PyDeadline_Get() function (GH-28674)Victor Stinner2021-10-011-0/+16
| | | | | | | | Add a private C API for deadlines: add _PyDeadline_Init() and _PyDeadline_Get() functions. * Add _PyTime_Add() and _PyTime_Mul() functions which compute t1+t2 and t1*t2 and clamp the result on overflow. * _PyTime_MulDiv() now uses _PyTime_Add() and _PyTime_Mul().
* bpo-41710: Document _PyTime_t API in pytime.h (GH-28647)Victor Stinner2021-09-301-0/+41
|
* bpo-41710: PyThread_acquire_lock_timed() clamps the timout (GH-28643)Victor Stinner2021-09-301-0/+2
| | | | | | | | | | | | | | | | | | | PyThread_acquire_lock_timed() now clamps the timeout into the [_PyTime_MIN; _PyTime_MAX] range (_PyTime_t type) if it is too large, rather than calling Py_FatalError() which aborts the process. PyThread_acquire_lock_timed() no longer uses MICROSECONDS_TO_TIMESPEC() to compute sem_timedwait() argument, but _PyTime_GetSystemClock() and _PyTime_AsTimespec_truncate(). Fix _thread.TIMEOUT_MAX value on Windows: the maximum timeout is 0x7FFFFFFF milliseconds (around 24.9 days), not 0xFFFFFFFF milliseconds (around 49.7 days). Set PY_TIMEOUT_MAX to 0x7FFFFFFF milliseconds, rather than 0xFFFFFFFF milliseconds. Fix PY_TIMEOUT_MAX overflow test: replace (us >= PY_TIMEOUT_MAX) with (us > PY_TIMEOUT_MAX).
* bpo-41710: Add pytime_add() and pytime_mul() (GH-28642)Victor Stinner2021-09-301-3/+5
| | | | | | Add pytime_add() and pytime_mul() functions to pytime.c to compute t+t2 and t*k with clamping to [_PyTime_MIN; _PyTime_MAX]. Fix pytime.h: _PyTime_FromTimeval() is not implemented on Windows.
* bpo-41710: Add _PyTime_AsTimespec_clamp() (GH-28629)Victor Stinner2021-09-301-5/+11
| | | | | | | | | | | | | | | Add the _PyTime_AsTimespec_clamp() function: similar to _PyTime_AsTimespec(), but clamp to _PyTime_t min/max and don't raise an exception. PyThread_acquire_lock_timed() now uses _PyTime_AsTimespec_clamp() to remove the Py_UNREACHABLE() code path. * Add _PyTime_AsTime_t() function. * Add PY_TIME_T_MIN and PY_TIME_T_MAX constants. * Replace _PyTime_AsTimeval_noraise() with _PyTime_AsTimeval_clamp(). * Add pytime_divide_round_up() function. * Fix integer overflow in pytime_divide(). * Add pytime_divmod() function.
* bpo-45211: Remember the stdlib dir during startup. (gh-28586)Eric Snow2021-09-281-0/+1
| | | | | During runtime startup we figure out the stdlib dir but currently throw that information away. This change preserves it and exposes it via PyConfig.stdlib_dir, _Py_GetStdlibDir(), and sys._stdlib_dir. https://bugs.python.org/issue45211