Stan Ulbrych [Mon, 15 Dec 2025 14:19:02 +0000 (14:19 +0000)]
Move doc on structure from devguide to `InternalDocs` (GH-142237)
Co-Authored-By: Paul Ross <apaulross@gmail.com> Co-Authored-By: Carol Willing <carolcode@willingconsulting.com> Co-Authored-By: Hugo van Kemenade <hugovk@users.noreply.github.com> Co-Authored-By: Ezio Melotti <ezio.melotti@gmail.com> Co-Authored-By: Adam Turner <9087854+aa-turner@users.noreply.github.com>
Cody Maloney [Mon, 15 Dec 2025 12:10:31 +0000 (04:10 -0800)]
gh-139871: Optimize bytearray construction with encoding (#142243)
When a `str` is encoded in `bytearray.__init__` the encoder tends to
create a new unique bytes object. Rather than allocate new memory and
copy the bytes use the already created bytes object as bytearray
backing. The bigger the `str` the bigger the saving.
Mean +- std dev: [main_encoding] 497 us +- 9 us -> [encoding] 14.2 us +- 0.3 us: 34.97x faster
Neil Schemenauer [Mon, 15 Dec 2025 04:27:37 +0000 (20:27 -0800)]
gh-132657: Use stronger memory ordering for so->mask. (gh-142735)
We need to use release/acquire ordering for the 'mask' member of the set
structure. Without this, `set_lookkey_threadsafe()` could be looking at
the old value of `table` but the new value of `mask`.
gh-138122: Add some screenshots to the profiling.sampling docs (#142676)
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com> Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com>
Neil Schemenauer [Sat, 13 Dec 2025 09:50:23 +0000 (01:50 -0800)]
gh-132657: Add lock-free set contains implementation (#132290)
This roughly follows what was done for dictobject to make a lock-free
lookup operation. With this change, the set contains operation scales much
better when used from multiple-threads. The frozenset contains performance
seems unchanged (as already lock-free).
Summary of changes:
* refactor set_lookkey() into set_do_lookup() which now takes a function
pointer that does the entry comparison. This is similar to dictobject and
do_lookup(). In an optimized build, the comparison function is inlined and
there should be no performance cost to this.
* change set_do_lookup() to return a status separately from the entry value
* add set_compare_frozenset() and use if the object is a frozenset. For the
free-threaded build, this avoids some overhead (locking, atomic operations,
incref/decref on key)
* use FT_ATOMIC_* macros as needed for atomic loads and stores
* use a deferred free on the set table array, if shared (only on free-threaded
build, normal build always does an immediate free)
* for free-threaded build, use explicit for loop to zero the table, rather than memcpy()
* when mutating the set, assign so->table to NULL while the change is a
happening. Assign the real table array after the change is done.
Alper [Fri, 12 Dec 2025 18:14:42 +0000 (10:14 -0800)]
gh-116738: Make zlib module thread-safe (gh-142432)
Makes the zlib module thread-safe free-threading build. Even though operations
are protected by locks, attributes exposed via PyMemberDef (eof, needs_input,
unused_data, unconsumed_tail) should still be stored atomically within locked
sections, since they can be read without acquiring the lock.
Sam Gross [Thu, 11 Dec 2025 21:23:19 +0000 (16:23 -0500)]
gh-142534: Avoid TSan warnings in dictobject.c (gh-142544)
There are places we use "relaxed" loads where C11 requires "consume" or
stronger. Unfortunately, compilers don't really implement "consume" so
fake it for our use in a way that avoids upsetting TSan.
AZero13 [Thu, 11 Dec 2025 21:18:52 +0000 (16:18 -0500)]
gh-142571: Check for errors before calling each syscall in `PyUnstable_CopyPerfMapFile()` (#142460)
Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com> Co-authored-by: Victor Stinner <vstinner@python.org> Co-authored-by: Pablo Galindo Salgado <Pablogsal@gmail.com>
If there are many untracked tuples, the GC will run too often, resulting
in poor performance. The fix is to include untracked tuples in the
"long lived" object count. The number of frozen objects is also now
included since the free-threaded GC must scan those too.
elenril [Thu, 11 Dec 2025 14:20:53 +0000 (15:20 +0100)]
gh-79986: Add parsing for References/In-Reply-To email headers (#137201)
This is a followup to 46d88a113142b26c01c95c93846a89318ba87ffc (#13397),
which added parsing for Message-ID. Similar handling is needed for the
other two identification headers.
Karolina Surma [Wed, 10 Dec 2025 12:09:41 +0000 (13:09 +0100)]
gh-131372: Include LDVERSION and EXE in base_interpreter value (#142256)
* Include LDVERSION and EXE in base_interpreter value
In Fedora, build-details.json created and installed for python3.14t
contains "/usr/bin/python3.14" as the base_interpreter value.
Create a correct string, taking into account both LDVERSION and EXE
config variables, similarly to how it's defined in altbininstall in Makefile.
* Add news
Signed-off-by: Filipe Laíns <lains@riseup.net>
---------
Signed-off-by: Filipe Laíns <lains@riseup.net> Co-authored-by: Filipe Laíns <lains@riseup.net>