summaryrefslogtreecommitdiffstats
path: root/Objects
Commit message (Collapse)AuthorAgeFilesLines
...
* gh-122943: Add the varpos parameter in _PyArg_UnpackKeywords (GH-126564)Serhiy Storchaka2024-11-0816-68/+119
| | | | Remove _PyArg_UnpackKeywordsWithVararg. Add comments for integer arguments of _PyArg_UnpackKeywords.
* gh-122943: Remove the object converter for var-positional parameter (GH-126560)Serhiy Storchaka2024-11-081-2/+2
|
* gh-122943: Rework support of var-positional parameter in Argument Clinic ↵Serhiy Storchaka2024-11-073-109/+99
| | | | | | | | | | | | | | | | | | (GH-122945) Move creation of a tuple for var-positional parameter out of _PyArg_UnpackKeywordsWithVararg(). Merge _PyArg_UnpackKeywordsWithVararg() with _PyArg_UnpackKeywords(). Add a new parameter in _PyArg_UnpackKeywords(). The "parameters" and "converters" attributes of ParseArgsCodeGen no longer contain the var-positional parameter. It is now available as the "varpos" attribute. Optimize code generation for var-positional parameter and reuse the same generating code for functions with and without keyword parameters. Add special converters for var-positional parameter. "tuple" represents it as a Python tuple and "array" represents it as a continuous array of PyObject*. "object" is a temporary alias of "tuple".
* gh-126298: Don't deduplicate slice constants based on equality (#126398)Michael Droettboom2024-11-071-1/+34
| | | | | | | | | | | | | | | * gh-126298: Don't deduplicated slice constants based on equality * NULL check for PySlice_New * Fix refcounting * Fix refcounting some more * Fix refcounting * Make tests more complete * Fix tests
* gh-126303: Fix pickling and copying of os.sched_param objects (GH-126336)Serhiy Storchaka2024-11-051-0/+6
|
* gh-115999: Implement thread-local bytecode and enable specialization for ↵mpage2024-11-043-13/+321
| | | | | | | | | `BINARY_OP` (#123926) Each thread specializes a thread-local copy of the bytecode, created on the first RESUME, in free-threaded builds. All copies of the bytecode for a code object are stored in the co_tlbc array on the code object. Threads reserve a globally unique index identifying its copy of the bytecode in all co_tlbc arrays at thread creation and release the index at thread destruction. The first entry in every co_tlbc array always points to the "main" copy of the bytecode that is stored at the end of the code object. This ensures that no bytecode is copied for programs that do not use threads. Thread-local bytecode can be disabled at runtime by providing either -X tlbc=0 or PYTHON_TLBC=0. Disabling thread-local bytecode also disables specialization. Concurrent modifications to the bytecode made by the specializing interpreter and instrumentation use atomics, with specialization taking care not to overwrite an instruction that was instrumented concurrently.
* gh-120026: soft deprecate Py_HUGE_VAL macro (#120027)Sergey B Kirpichev2024-11-011-1/+1
| | | Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
* gh-90370: Argument Clinic: avoid temporary tuple creation for varargs (#126064)Sergey B Kirpichev2024-10-312-93/+65
| | | | | | | Avoid temporary tuple creation when all arguments either positional-only or vararg. Objects/setobject.c and Modules/gcmodule.c adapted. This fixes slight performance regression for set methods, introduced by gh-115112.
* gh-126072: do not add `None` to `co_consts` if there is no docstring (GH-126101)Xuanteng Huang2024-10-301-1/+2
|
* gh-116938: Fix `dict.update` docstring and remove erraneous full stop from ↵Prometheus33752024-10-291-2/+2
| | | | | `dict` documentation (#125421) Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
* GH-125837: Split `LOAD_CONST` into three. (GH-125972)Mark Shannon2024-10-291-2/+0
| | | | | | | | * Add LOAD_CONST_IMMORTAL opcode * Add LOAD_SMALL_INT opcode * Remove RETURN_CONST opcode
* gh-126012: Add `__class_getitem__` to `memoryview` (#126013)Brian Schubert2024-10-271-0/+1
| | | | Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com> Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
* gh-121654: Add PyType_Freeze() function (#122457)Victor Stinner2024-10-251-13/+52
| | | Co-authored-by: Petr Viktorin <encukou@gmail.com>
* gh-125900: Clean-up logic around immortalization in free-threading (#125901)Sam Gross2024-10-241-14/+6
| | | | | | | | | * Remove `@suppress_immortalization` decorator * Make suppression flag per-thread instead of per-interpreter * Suppress immortalization in `eval()` to avoid refleaks in three tests (test_datetime.test_roundtrip, test_logging.test_config8_ok, and test_random.test_after_fork). * frozenset() is constant, but not a singleton. When run multiple times, the test could fail due to constant interning.
* gh-123930: Better error for "from imports" when script shadows module (#123929)Shantanu2024-10-241-12/+16
|
* gh-124218: Avoid refcount contention on builtins module (GH-125847)Sam Gross2024-10-243-42/+41
| | | | | | | This replaces `_PyEval_BuiltinsFromGlobals` with `_PyDict_LoadBuiltinsFromGlobals`, which returns a new reference instead of a borrowed reference. Internally, the new function uses per-thread reference counting when possible to avoid contention on the refcount fields on the builtins module.
* gh-125286: Share the Main Refchain With Legacy Interpreters (gh-125709)Eric Snow2024-10-232-56/+44
| | | | | They used to be shared, before 3.12. Returning to sharing them resolves a failure on Py_TRACE_REFS builds. Co-authored-by: Petr Viktorin <encukou@gmail.com>
* fix grammar in comment in dictobject.c (#125822)Arjun Singh2024-10-221-1/+1
|
* gh-124218: Use per-thread reference counting for globals and builtins (#125713)Sam Gross2024-10-213-7/+52
| | | | Use per-thread refcounting for the reference from function objects to the globals and builtins dictionaries.
* gh-125590: Allow FrameLocalsProxy to delete and pop keys from extra locals ↵Tian Gao2024-10-211-6/+70
| | | | (#125616)
* gh-125608: Trigger dictionary watchers when inline values change (#125611)Sam Gross2024-10-211-6/+15
| | | | | Dictionary watchers on an object's attributes dictionary (`object.__dict__`) were not triggered when the managed dictionary used the object's inline values.
* gh-125604: Move _Py_AuditHookEntry, etc. Out of pycore_runtime.h (gh-125605)Eric Snow2024-10-181-0/+1
| | | | | | | | | | | | This is essentially a cleanup, moving a handful of API declarations to the header files where they fit best, creating new ones when needed. We do the following: * add pycore_debug_offsets.h and move _Py_DebugOffsets, etc. there * inline struct _getargs_runtime_state and struct _gilstate_runtime_state in _PyRuntimeState * move struct _reftracer_runtime_state to the existing pycore_object_state.h * add pycore_audit.h and move to it _Py_AuditHookEntry , _PySys_Audit(), and _PySys_ClearAuditHooks * add audit.h and cpython/audit.h and move the existing audit-related API there *move the perfmap/trampoline API from cpython/sysmodule.h to cpython/ceval.h, and remove the now-empty cpython/sysmodule.h
* gh-125017: Fix refleak from GH-125636 (GH-125664)Zachary Ware2024-10-171-0/+1
|
* gh-125017: Fix crash on premature access to classmethod/staticmethod ↵Jelle Zijlstra2024-10-171-14/+27
| | | | annotations (#125636)
* gh-124218: Use per-thread refcounts for code objects (#125216)Sam Gross2024-10-153-6/+12
| | | | | | | Use per-thread refcounting for the reference from function objects to their corresponding code object. This can be a source of contention when frequently creating nested functions. Deferred refcounting alone isn't a great fit here because these references are on the heap and may be modified by other libraries.
* GH-125323: Convert DECREF_INPUTS_AND_REUSE_FLOAT into a function that takes ↵Mark Shannon2024-10-141-0/+35
| | | | PyStackRefs. (GH-125439)
* gh-124787: Fix `TypeAliasType` and incorrect `type_params` (#124795)sobolevn2024-10-111-11/+86
| | | Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
* gh-125221: Fix free-threading data race in `object.__reduce_ex__` (#125267)Sam Gross2024-10-112-15/+13
|
* gh-125196: Use PyUnicodeWriter for repr(dict) (#125270)Victor Stinner2024-10-101-36/+36
|
* GH-125174: Make immortal objects more robust, following design from PEP 683 ↵Mark Shannon2024-10-105-12/+16
| | | | (GH-125251)
* gh-124153: Simplify PyType_GetBaseByToken (GH-124488)neonene2024-10-101-80/+43
|
* gh-125196: Use PyUnicodeWriter for repr(tuple) (#125242)Victor Stinner2024-10-101-26/+24
|
* gh-125196: Add a free list to PyUnicodeWriter (#125227)Victor Stinner2024-10-102-4/+10
|
* gh-125196: PyUnicodeWriter_Discard(NULL) does nothing (#125222)Victor Stinner2024-10-092-3/+4
|
* gh-125196: Use PyUnicodeWriter for repr(structseq) (#125219)Victor Stinner2024-10-091-41/+24
| | | | | | | | Replace the private _PyUnicodeWriter with the public PyUnicodeWriter. * Avoid temporary PyUnicode_DecodeUTF8(): call PyUnicodeWriter_WriteUTF8() instead. * Avoid temporary PyObject_Repr(): call PyUnicodeWriter_WriteRepr() instead.
* gh-125196: Add fast-path for int in PyUnicodeWriter_WriteStr() (#125214)Victor Stinner2024-10-091-0/+8
| | | | PyUnicodeWriter_WriteStr() and PyUnicodeWriter_WriteRepr() now call directly _PyLong_FormatWriter() if the argument is an int.
* gh-125196: Use PyUnicodeWriter for repr(list) (#125202)Victor Stinner2024-10-091-22/+23
| | | | | | Replace the private _PyUnicodeWriter with the public PyUnicodeWriter. Replace PyObject_Repr() + _PyUnicodeWriter_WriteStr() with PyUnicodeWriter_WriteRepr().
* gh-116510: Fix a Crash Due to Shared Immortal Interned Strings (gh-124865)Eric Snow2024-10-092-6/+86
| | | | | | | | | | Fix a crash caused by immortal interned strings being shared between sub-interpreters that use basic single-phase init. In that case, the string can be used by an interpreter that outlives the interpreter that created and interned it. For interpreters that share obmalloc state, also share the interned dict with the main interpreter. This is an un-revert of gh-124646 that then addresses the Py_TRACE_REFS failures identified by gh-124785.
* gh-115754: Use Py_GetConstant(Py_CONSTANT_EMPTY_STR) (#125194)Victor Stinner2024-10-093-7/+7
| | | | | Replace PyUnicode_New(0, 0), PyUnicode_FromString("") and PyUnicode_FromStringAndSize("", 0) with Py_GetConstant(Py_CONSTANT_EMPTY_STR).
* gh-115754: Use Py_GetConstant(Py_CONSTANT_EMPTY_BYTES) (#125195)Victor Stinner2024-10-091-1/+1
| | | | Replace PyBytes_FromString("") and PyBytes_FromStringAndSize("", 0) with Py_GetConstant(Py_CONSTANT_EMPTY_BYTES).
* gh-111178: Fix function signatures in codeobject.c (#125180)Victor Stinner2024-10-091-32/+48
|
* gh-111178: Fix function signatures in cellobject.c (#125182)Victor Stinner2024-10-091-16/+23
|
* gh-124502: Remove _PyUnicode_EQ() function (#125114)Victor Stinner2024-10-092-33/+8
| | | | | | * Replace unicode_compare_eq() with unicode_eq(). * Use unicode_eq() in setobject.c. * Replace _PyUnicode_EQ() with _PyUnicode_Equal(). * Remove unicode_compare_eq() and _PyUnicode_EQ().
* gh-125063: Emit slices as constants in the bytecode compiler (#125064)Michael Droettboom2024-10-082-1/+2
| | | | | | | | | | | | | | | | | | | | | | | * Make slices marshallable * Emit slices as constants * Update Python/marshal.c Co-authored-by: Peter Bierma <zintensitydev@gmail.com> * Refactor codegen_slice into two functions so it always has the same net effect * Fix for free-threaded builds * Simplify marshal loading of slices * Only return SUCCESS/ERROR from codegen_slice --------- Co-authored-by: Mark Shannon <mark@hotpy.org> Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
* gh-124502: Optimize unicode_eq() (#125105)Victor Stinner2024-10-081-7/+12
|
* gh-115999: Stop the world when invalidating function versions (#124997)mpage2024-10-081-33/+56
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Stop the world when invalidating function versions The tier1 interpreter specializes `CALL` instructions based on the values of certain function attributes (e.g. `__code__`, `__defaults__`). The tier1 interpreter uses function versions to verify that the attributes of a function during execution of a specialization match those seen during specialization. A function's version is initialized in `MAKE_FUNCTION` and is invalidated when any of the critical function attributes are changed. The tier1 interpreter stores the function version in the inline cache during specialization. A guard is used by the specialized instruction to verify that the version of the function on the operand stack matches the cached version (and therefore has all of the expected attributes). It is assumed that once the guard passes, all attributes will remain unchanged while executing the rest of the specialized instruction. Stopping the world when invalidating function versions ensures that all critical function attributes will remain unchanged after the function version guard passes in free-threaded builds. It's important to note that this is only true if the remainder of the specialized instruction does not enter and exit a stop-the-world point. We will stop the world the first time any of the following function attributes are mutated: - defaults - vectorcall - kwdefaults - closure - code This should happen rarely and only happens once per function, so the performance impact on majority of code should be minimal. Additionally, refactor the API for manipulating function versions to more clearly match the stated semantics.
* gh-123378: fix a crash in `UnicodeError.__str__` (#124935)Bénédikt Tran2024-10-081-45/+66
|
* gh-124502: Add PyUnicode_Equal() function (#124504)Victor Stinner2024-10-071-0/+18
|
* Use _PyLong_GetOne() and _PyLong_GetZero() in long_invmod() (#125044)Victor Stinner2024-10-071-11/+2
| | | These functions cannot fail.
* gh-111178: Fix function signatures in genobject.c (#124970)Victor Stinner2024-10-051-206/+271
| | | | | * Add "CAST" macros. * Rename parameters/variables "o" to "ag", "ags", "agw" or "agt" in some functions.