summaryrefslogtreecommitdiffstats
path: root/Include
Commit message (Collapse)AuthorAgeFilesLines
* GH-128375: Better instrument for `FOR_ITER` (GH-128445)Mark Shannon2025-01-066-101/+132
|
* gh-127350: Add Py_fopen() and Py_fclose() functions (#127821)Victor Stinner2025-01-061-2/+8
|
* gh-128089: Add PYC magic number for VALUE_WITH_FAKE_GLOBALS (#128097)Jelle Zijlstra2025-01-061-1/+1
| | | | Assign 3610 PYC magic number to VALUE_WITH_FAKE_GLOBALS format of annotationlib.
* gh-128137: Update PyASCIIObject to handle interned field with the atomic ↵Donghee Na2025-01-051-7/+13
| | | | operation (gh-128196)
* gh-127787: refactor helpers for `PyUnicodeErrorObject` internal interface ↵Bénédikt Tran2025-01-031-0/+6
| | | | | | | | | | | | | | | | | | | | | | (GH-127789) - Unify `get_unicode` and `get_string` in a single function. - Allow to retrieve the underlying `object` attribute, its size, and the adjusted 'start' and 'end', all at once. Add a new `_PyUnicodeError_GetParams` internal function for this. (In `exceptions.c`, it's somewhat common to not need all the attributes, but the compiler has opportunity to inline the function and optimize unneeded work away. Outside that file, we'll usually need all or most of them at once.) - Use a common implementation for the following functions: - `PyUnicode{Decode,Encode}Error_GetEncoding` - `PyUnicode{Decode,Encode,Translate}Error_GetObject` - `PyUnicode{Decode,Encode,Translate}Error_{Get,Set}Reason` - `PyUnicode{Decode,Encode,Translate}Error_{Get,Set}{Start,End}`
* gh-128262: Allow specialization of calls to classes with __slots__ (GH-128263)Ken Jin2024-12-311-1/+1
|
* gh-114203: Optimise simple recursive critical sections (#128126)T. Wouters2024-12-231-0/+14
| | | | | | | Add a fast path to (single-mutex) critical section locking _iff_ the mutex is already held by the currently active, top-most critical section of this thread. This can matter a lot for indirectly recursive critical sections without intervening critical sections.
* GH-127705: Add debug mode for `_PyStackRef`s inspired by HPy debug mode ↵Mark Shannon2024-12-202-0/+119
| | | | (GH-128121)
* GH-122548: Correct magic number comment (GH-128115)Mark Shannon2024-12-201-1/+2
| | | Correct magic number comment
* gh-127274: Defer nested methods (#128012)mpage2024-12-192-0/+4
| | | | | | | Methods (functions defined in class scope) are likely to be cleaned up by the GC anyway. Add a new code flag, `CO_METHOD`, that is set for functions defined in a class scope. Use that when deciding to defer functions.
* gh-115999: Specialize `STORE_ATTR` in free-threaded builds. (gh-127838)Neil Schemenauer2024-12-194-103/+109
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Add `_PyDictKeys_StringLookupSplit` which does locking on dict keys and use in place of `_PyDictKeys_StringLookup`. * Change `_PyObject_TryGetInstanceAttribute` to use that function in the case of split keys. * Add `unicodekeys_lookup_split` helper which allows code sharing between `_Py_dict_lookup` and `_PyDictKeys_StringLookupSplit`. * Fix locking for `STORE_ATTR_INSTANCE_VALUE`. Create `_GUARD_TYPE_VERSION_AND_LOCK` uop so that object stays locked and `tp_version_tag` cannot change. * Pass `tp_version_tag` to `specialize_dict_access()`, ensuring the version we store on the cache is the correct one (in case of it changing during the specalize analysis). * Split `analyze_descriptor` into `analyze_descriptor_load` and `analyze_descriptor_store` since those don't share much logic. Add `descriptor_is_class` helper function. * In `specialize_dict_access`, double check `_PyObject_GetManagedDict()` in case we race and dict was materialized before the lock. * Avoid borrowed references in `_Py_Specialize_StoreAttr()`. * Use `specialize()` and `unspecialize()` helpers. * Add unit tests to ensure specializing happens as expected in FT builds. * Add unit tests to attempt to trigger data races (useful for running under TSAN). * Add `has_split_table` function to `_testinternalcapi`.
* GH-122548: Implement branch taken and not taken events for sys.monitoring ↵Mark Shannon2024-12-198-116/+168
| | | | (GH-122564)
* gh-128008: Add `PyWeakref_IsDead()` (GH-128009)Sam Gross2024-12-191-0/+3
| | | | | | | | | The `PyWeakref_IsDead()` function tests if a weak reference is dead without any side effects. Although you can also detect if a weak reference is dead using `PyWeakref_GetRef()`, that function returns a strong reference that must be `Py_DECREF()`'d, which can introduce side effects if the last reference is concurrently dropped (at least in the free threading build).
* gh-115999: Enable BINARY_SUBSCR_GETITEM for free-threaded build (gh-127737)Donghee Na2024-12-193-3/+4
|
* gh-128033: change `PyMutex_LockFast` to take `PyMutex` as argument (#128054)Kumar Aditya2024-12-182-4/+5
| | | Change `PyMutex_LockFast` to take `PyMutex` as argument.
* Merge branch 'main' of https://github.com/python/cpythonHugo van Kemenade2024-12-171-0/+12
|\
| * gh-126742: Add _PyErr_SetLocaleString, use it for gdbm & dlerror messages ↵Bénédikt Tran2024-12-171-0/+12
| | | | | | | | | | | | | | | | (GH-126746) - Add a helper to set an error from locale-encoded `char*` - Use the helper for gdbm & dlerror messages Co-authored-by: Victor Stinner <vstinner@python.org>
* | Post 3.14.0a3Hugo van Kemenade2024-12-171-1/+1
| |
* | Python 3.14.0a3v3.14.0a3Hugo van Kemenade2024-12-171-2/+2
|/
* gh-126907: make `atexit` thread safe in free-threading (#127935)Peter Bierma2024-12-161-9/+15
| | | | Co-authored-by: Victor Stinner <vstinner@python.org> Co-authored-by: Kumar Aditya <kumaraditya@python.org>
* gh-127599: Fix _Py_RefcntAdd missing calls to ↵Ed Nutting2024-12-152-0/+11
| | | | | | | | _Py_INCREF_STAT_INC/_Py_INCREF_IMMORTAL_STAT_INC (#127717) Previously, `_Py_RefcntAdd` hasn't called `_Py_INCREF_STAT_INC/_Py_INCREF_IMMORTAL_STAT_INC` which is incorrect. Now it has been fixed.
* gh-115999: Specialize loading attributes from modules in free-threaded ↵mpage2024-12-133-78/+83
| | | | | | | | | builds (#127711) We use the same approach that was used for specialization of LOAD_GLOBAL in free-threaded builds: _CHECK_ATTR_MODULE is renamed to _CHECK_ATTR_MODULE_PUSH_KEYS; it pushes the keys object for the following _LOAD_ATTR_MODULE_FROM_KEYS (nee _LOAD_ATTR_MODULE). This arrangement avoids having to recheck the keys version. _LOAD_ATTR_MODULE is renamed to _LOAD_ATTR_MODULE_FROM_KEYS; it loads the value from the keys object pushed by the preceding _CHECK_ATTR_MODULE_PUSH_KEYS at the cached index.
* gh-102471, PEP 757: Add PyLong import and export API (#121339)Victor Stinner2024-12-131-0/+38
| | | | | Co-authored-by: Sergey B Kirpichev <skirpichev@gmail.com> Co-authored-by: Steve Dower <steve.dower@microsoft.com> Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
* GH-126833: Dumps graphviz representation of executor graph. (GH-126880)Mark Shannon2024-12-135-0/+12
|
* gh-126868: Add freelist for compact int objects (GH-126865)Pieter Eendebak2024-12-132-0/+4
|
* GH-125174: Don't use `UINT32_MAX` in header file (GH-127863)Mark Shannon2024-12-131-1/+1
|
* gh-127879: Fix data race in `_PyFreeList_Push` (#127880)Sam Gross2024-12-121-1/+1
| | | | | Writes to the `ob_tid` field need to use atomics because it may be concurrently read by a non-locking dictionary, list, or structmember read.
* GH-125174: Fix compiler warning (GH-127860)Mark Shannon2024-12-121-1/+1
| | | Fix compiler warning
* GH-125174: Mark objects as statically allocated. (#127797)Mark Shannon2024-12-113-11/+61
| | | | | * Set a bit in the unused part of the refcount on 64 bit machines and the free-threaded build. * Use the top of the refcount range on 32 bit machines
* GH-127058: Make `PySequence_Tuple` safer and probably faster. (#127758)Mark Shannon2024-12-111-1/+1
| | | | * Use a small buffer, then list when constructing a tuple from an arbitrary sequence.
* gh-127791: Fix, document, and test `PyUnstable_AtExit` (#127793)Peter Bierma2024-12-111-1/+0
|
* Add `extern "C"` around `PyTraceMalloc_` functions. (#127772)Peter Hawkins2024-12-111-0/+6
| | | | Pretty much everything else exported by Python.h has an extern "C" annotation, yet this header appears to be missing one.
* gh-126925: Modify how iOS test results are gathered (#127592)Russell Keith-Magee2024-12-091-0/+3
| | | | | | | Adds a `use_system_log` config item to enable stdout/stderr redirection for Apple platforms. This log streaming is then used by a new iOS test runner script, allowing the display of test suite output at runtime. The iOS test runner script can be used by any Python project, not just the CPython test suite.
* gh-127314: Don't mention the GIL when calling without a thread state on the ↵Peter Bierma2024-12-061-0/+8
| | | | | free-threaded build (#127315) Co-authored-by: Victor Stinner <vstinner@python.org>
* gh-127582: Make object resurrection thread-safe for free threading. (GH-127612)Sam Gross2024-12-051-0/+44
| | | | | | | | | | | | Objects may be temporarily "resurrected" in destructors when calling finalizers or watcher callbacks. We previously undid the resurrection by decrementing the reference count using `Py_SET_REFCNT`. This was not thread-safe because other threads might be accessing the object (modifying its reference count) if it was exposed by the finalizer, watcher callback, or temporarily accessed by a racy dictionary or list access. This adds internal-only thread-safe functions for temporary object resurrection during destructors.
* GH-126795: Increase the JIT side-exit threshold from 64 to 4096 (GH-127155)Brandt Bucher2024-12-041-4/+3
|
* gh-115999: Enable specialization of `CALL` instructions in free-threaded ↵mpage2024-12-031-0/+14
| | | | | | | | | | | | | | | | | | | | | | builds (#127123) The CALL family of instructions were mostly thread-safe already and only required a small number of changes, which are documented below. A few changes were needed to make CALL_ALLOC_AND_ENTER_INIT thread-safe: Added _PyType_LookupRefAndVersion, which returns the type version corresponding to the returned ref. Added _PyType_CacheInitForSpecialization, which takes an init method and the corresponding type version and only populates the specialization cache if the current type version matches the supplied version. This prevents potentially caching a stale value in free-threaded builds if we race with an update to __init__. Only cache __init__ functions that are deferred in free-threaded builds. This ensures that the reference to __init__ that is stored in the specialization cache is valid if the type version guard in _CHECK_AND_ALLOCATE_OBJECT passes. Fix a bug in _CREATE_INIT_FRAME where the frame is pushed to the stack on failure. A few other miscellaneous changes were also needed: Use {LOCK,UNLOCK}_OBJECT in LIST_APPEND. This ensures that the list's per-object lock is held while we are appending to it. Add missing co_tlbc for _Py_InitCleanup. Stop/start the world around setting the eval frame hook. This allows us to read interp->eval_frame non-atomically and preserves the behavior of _CHECK_PEP_523 documented below.
* gh-127271: Replace use of PyCell_GET/SET (gh-127272)Neil Schemenauer2024-12-032-2/+8
| | | | | | | | | | | | | | | | | | * Replace uses of `PyCell_GET` and `PyCell_SET`. These macros are not safe to use in the free-threaded build. Use `PyCell_GetRef()` and `PyCell_SetTakeRef()` instead. * Since `PyCell_GetRef()` returns a strong rather than borrowed ref, some code restructuring was required, e.g. `frame_get_var()` returns a strong ref now. * Add critical sections to `PyCell_GET` and `PyCell_SET`. * Move critical_section.h earlier in the Python.h file. * Add `PyCell_GET` to the free-threading howto table of APIs that return borrowed refs. * Add additional unit tests for free-threading.
* gh-117657: TSAN Fix races in `PyMember_Get` and `PyMember_Set` for C ↵Daniele Parmeggiani2024-12-035-1/+419
| | | | extensions (GH-123211)
* gh-127411: Fix invalid conversion of load of TLBC array when compiled in C++ ↵mpage2024-12-022-2/+9
| | | | | (#127466) Cast the result of the load to the correct type
* gh-115999: Use light-weight lock for UNPACK_SEQUENCE_LIST (gh-127514)Donghee Na2024-12-022-2/+2
|
* GH-126491: GC: Mark objects reachable from roots before doing cycle ↵Mark Shannon2024-12-025-4/+16
| | | | | | | | | | | | | collection (GH-127110) * Mark almost all reachable objects before doing collection phase * Add stats for objects marked * Visit new frames before each increment * Update docs * Clearer calculation of work to do.
* gh-115999: Add partial free-thread specialization for BINARY_SUBSCR (gh-127227)Donghee Na2024-12-023-2/+5
|
* gh-69639: Add mixed-mode rules for complex arithmetic (C-like) (GH-124829)Sergey B Kirpichev2024-11-262-0/+8
| | | | | | | | | | | | | | | "Generally, mixed-mode arithmetic combining real and complex variables should be performed directly, not by first coercing the real to complex, lest the sign of zero be rendered uninformative; the same goes for combinations of pure imaginary quantities with complex variables." (c) Kahan, W: Branch cuts for complex elementary functions. This patch implements mixed-mode arithmetic rules, combining real and complex variables as specified by C standards since C99 (in particular, there is no special version for the true division with real lhs operand). Most C compilers implementing C99+ Annex G have only these special rules (without support for imaginary type, which is going to be deprecated in C2y).
* gh-119180: Add VALUE_WITH_FAKE_GLOBALS format to annotationlib (#124415)Jelle Zijlstra2024-11-261-0/+7
|
* gh-126612: Include stack effects of uops when computing maximum stack depth ↵mpage2024-11-261-0/+925
| | | | (#126894)
* gh-127022: Simplify `PyStackRef_FromPyObjectSteal` (#127024)Sam Gross2024-11-221-4/+10
| | | | | | | | | This gets rid of the immortal check in `PyStackRef_FromPyObjectSteal()`. Overall, this improves performance about 2% in the free threading build. This also renames `PyStackRef_Is()` to `PyStackRef_IsExactly()` because the macro requires that the tag bits of the arguments match, which is only true in certain special cases.
* gh-115999: Add free-threaded specialization for `UNPACK_SEQUENCE` (#126600)Kirill Podoprigora2024-11-222-2/+2
| | | | | | | | | | | Add free-threaded specialization for `UNPACK_SEQUENCE` opcode. `UNPACK_SEQUENCE_TUPLE/UNPACK_SEQUENCE_TWO_TUPLE` are already thread safe since tuples are immutable. `UNPACK_SEQUENCE_LIST` is not thread safe because of nature of lists (there is nothing preventing another thread from adding items to or removing them the list while the instruction is executing). To achieve thread safety we add a critical section to the implementation of `UNPACK_SEQUENCE_LIST`, especially around the parts where we check the size of the list and push items onto the stack. --------- Co-authored-by: Matt Page <mpage@meta.com> Co-authored-by: mpage <mpage@cs.stanford.edu>
* gh-127117: Ensure the Correct Last Fields of PyInterpreterState and of ↵Eric Snow2024-11-222-7/+10
| | | | | _PyRuntimeState (gh-127118) We add some comments so contributors can be aware and we move one out-of-place field up.
* Improve comment for co_nlocalsplus (#126993)Jacob Bower2024-11-211-1/+2
|