1292 Commits
Author SHA1 Message Date
Kumar Aditya b1e32ff4f3 gh-159580: use _Py_INCREF_TYPE in object.__class__ (#160424) 2026-10-23 08:33:57 +00:00
Neil Schemenauer b70a5128c4 gh-159431: Handle immortal objects in _PyObject_XDecRefDelayed() (gh-159433)
Skip immortal objects both when queueing and when processing the
queue, and remove the now redundant caller-side checks.
2026-10-14 14:11:48 -07:00
Abhishek Tiwari f674db1803 gh-149816: Fix race in subtype_getweakref in free-threading build (gh-150247) 2026-10-12 11:33:36 -07:00
Kumar Aditya d4f52c445b gh-157526: Call __instancecheck__ and __subclasscheck__ without creating a bound method (#157670) 2026-09-22 11:16:30 +05:30
Kumar Aditya 1ac3bfaacc gh-156910: fix deadlock in type_set_abstractmethods under free-threading (#156948) 2026-09-09 11:50:58 +05:30
Neil Schemenauer f381d1634c gh-155978: Fix leak in update_slot_after_setattr() (#155979) 2026-08-18 07:55:08 +05:30
Neil Schemenauer 50fcb9193d gh-155400: Fix deadlock with type_lock_prevent_release() (#155401) 2026-08-15 10:53:33 +05:30
Neil Schemenauer 07624ef11b gh-151377: Fix races updating type slots and subclasses (#155370) 2026-08-15 09:21:44 +05:30
Maurycy Pawłowski-Wieroński d2f4649592 gh-145685: Remove _PySeqLock that is not used anymore (gh-155243) 2026-08-05 21:59:28 -04:00
Kumar Aditya daf09e17bf gh-145685: per-type method cache implementation (#150160) 2026-07-21 14:11:22 +05:30
Santhosh .I 🦇 f160f16373 gh-151912: Fix segfault in type() with NULL tp_new metaclasses (#151916) 2026-07-14 21:49:03 +05:30
Dino Viehland 20921922fa gh-150490: Raise PyType_Modified for insertion into split dictionary (take 2) (#152914)
Raise PyType_Modified for insertion into split dictionary - now with better locking discipline in free-threaded builds
2026-07-06 12:56:32 -07:00
Neil Schemenauer 9626ef87f4 gh-152238: Revert gh-150490 and gh-152200. (gh-152232)
Revert commits:
    gh-151593: Fix dead lock in PyDict insert_split_key() (#152200)
    gh-150490: Raise PyType_Modified for insertion into split dictionary (#150489)

For gh-150489, it violates locking discipline and results in deadlocks,
gh-151593 is an example of it being hit in CI.  The attempted fix 
gh-152200 avoids the deadlock but introduces a data-race.  The race
window is small but can be triggered with pure Python code.
2026-06-26 11:20:41 -07:00
Ivy XuandStan Ulbrych 7928a8b730 gh-151126: Add missing PyErr_NoMemory() in type_from_slots_or_spec (#151582)
Co-authored-by: Stan Ulbrych <stan@python.org>
2026-06-23 15:48:11 +01:00
Petr Viktorin 16185e9fe2 gh-149044: Improve Py_tp_base[s] docs & error message for non-type bases (GH-151252)
The initial implementation of PEP 820 worsened the error message
when non-types are given as base types in Py_tp_bases & Py_tp_base.
Bring back the 'bases must be types' wording and add a 'got' note for
easier debugging.

Improve slot ID documentation, and soft-deprecate Py_tp_base
(as per the PEP).
2026-06-17 15:27:02 +02:00
Victor Stinner 0ec7c9d17e gh-146102: Fix type slot_bf_getbuffer() error handling (#151346)
Call PyBuffer_Release() if PyObject_GC_New() fails.

Fix also bytes_join(): only call Py_DECREF(item) after formatting the
error message which uses item.
2026-06-15 11:47:58 +02:00
JasonMendoza2008 ecbd31ee39 gh-137759: Replace _PyObject_HashFast() with PyObject_Hash() in setobject.c (#137828)
Replace also _PyObject_HashFast() with PyObject_Hash()
in _collections._count_elements().

Rename _PyObject_HashFast() to _PyObject_HashDictKey(),
and mark it as Py_ALWAYS_INLINE.

Only use _PyObject_HashDictKey() on dictionaries.
2026-06-15 11:31:04 +02:00
Dino Viehland efb2fffae1 gh-150490: Raise PyType_Modified for insertion into split dictionary (#150489)
Raise PyType_Modified for insertion into split dictionary
2026-06-11 09:38:31 -07:00
Thomas Kowalski 1ec6596828 gh-150858: fix data race while changing __qualname__ of a type object(#150859) 2026-06-11 15:07:36 +00:00
Serhiy Storchaka e1e06be119 gh-150285: Fix too long docstrings in builtins (GH-150293)
* gh-150285: Fix too long docstrings in builtins

* Revert bytes and bytearray class multiline docstrings to make IDLE happy.
2026-05-24 15:03:32 +03:00
Hai Zhu e7eaed5614 gh-148450: abc.register needs to update type_version when tp_flags is changed (#148623) 2026-05-23 13:55:44 +05:30
Kumar Aditya 94bca40ff0 gh-148906: fix performance scaling of descriptors on free-threading (#148915) 2026-05-13 23:03:59 +05:30
49918f5b0c gh-149481: skip FOR_ITER inline specialization for Python __next__ (#149491)
Co-authored-by: Savannah Ostrowski <savannah@python.org>
Co-authored-by: Stan Ulbrych <stan@python.org>
2026-05-07 23:02:04 +00:00
Anuj Nitin Bharambe f6d16a0d70 gh-149216: Notify type watchers on heap type deallocation (GH-149236)
Authored-by: Anuj Bharambe <anujnitinb@gmail.com>
2026-05-05 11:24:07 +01:00
Petr ViktorinandPeter Bierma 508b49845d gh-149044: Implement PEP 820 – PySlot: Unified slot system for the C API (GH-149055)
Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
2026-05-05 09:18:04 +02:00
Kumar Aditya 29917d51ab gh-148907: fix performance regression in PyType_GetModuleByDef on free-threading (#148908) 2026-04-23 16:42:57 +05:30
Kumar Aditya 458aca9237 gh-131798: fold super method lookups in JIT (#148231) 2026-04-09 13:25:01 +05:30
8923ca418c gh-145921: Add "_DuringGC" functions for tp_traverse (GH-145925)
There are newly documented restrictions on tp_traverse:

    The traversal function must not have any side effects.
    It must not modify the reference counts of any Python
    objects nor create or destroy any Python objects.

* Add several functions that are guaranteed side-effect-free,
  with a _DuringGC suffix.
* Use these in ctypes
* Consolidate tp_traverse docs in gcsupport.rst, moving unique
  content from typeobj.rst there

Co-authored-by: Lysandros Nikolaou <lisandrosnik@gmail.com>
Co-authored-by: Victor Stinner <vstinner@python.org>
2026-04-08 09:15:11 +02:00
Wulian233 c398490fbf gh-148074: Fix typeobject.c missing error return (#148075) 2026-04-04 21:04:55 +05:30
sunmy2019 bbf7fb2c15 gh-146615: Fix format specifiers in Objects/ directory (GH-146620) 2026-03-31 10:59:48 +03:00
Kumar Aditya 8e10bd77ea gh-146587: fix type slot assignment incase of multiple slots for same name (#146593) 2026-03-30 18:07:38 +05:30
Sergey MiryanovandVictor Stinner a933e9ccee GH-145247: Use _PyTuple_FromPair[Steal] in Objects (#145884)
Co-authored-by: Victor Stinner <vstinner@python.org>
2026-03-28 00:01:01 +00:00
Kumar Aditya 495178ab05 gh-146453: fix _PyType_LookupByVersion for types with fixed pre-defined version tags (#146454) 2026-03-26 14:36:55 +05:30
Sergey Miryanov f105265538 GH-132042: Fix calculation of slotdef index in update_one_slot() (#145880) 2026-03-12 23:16:53 +01:00
Sam Gross cd52172831 gh-145685: Improve scaling of type attribute lookups (gh-145774)
Avoid locking in the PyType_Lookup cache-miss path if the type's
tp_version_tag is already valid.
2026-03-12 13:30:36 -04:00
Sam Gross bdf6de8c3f gh-145685: Avoid contention on TYPE_LOCK in super() lookups (gh-145775) 2026-03-11 07:19:32 -04:00
Sam Gross f26eca7732 gh-145685: Update find_name_in_mro() to return a _PyStackRef (gh-145693) 2026-03-10 12:47:12 -04:00
Sam Gross 0b65c88c2a gh-145685: Stop the world when updating MRO of existing types (gh-145707)
We already have a stop-the-world pause elsewhere in this code path
(type_set_bases) and this makes will make it easier to avoid contention
on the TYPE_LOCK when looking up names in the MRO hierarchy.

Also use deferred reference counting for non-immortal MROs.
2026-03-09 18:41:07 -04:00
Sam Gross 1d091a336e gh-145566: Skip stop-the-world when reassigning __class__ on newly created objects (gh-145567) 2026-03-06 12:01:06 -05:00
Victor Stinner 95f56b1206 gh-141510: Return frozendict unmodified in PyDict_Copy() (#145505)
Add also the internal _PyDict_CopyAsDict() function.
2026-03-04 19:11:00 +00:00
Sam Gross 8a7eb8b2ab gh-145500: Delete _PyType_GetMRO (gh-145501) 2026-03-04 13:32:43 -05:00
Stan Ulbrych f8d2f9fe67 gh-145118: Add frozendict support to type() (#145124) 2026-03-02 20:45:03 +01:00
Sam GrossandVictor Stinner d891b2bbd1 gh-139103: Improve namedtuple scaling in free-threaded build (gh-144332)
Add `_Py_type_getattro_stackref`, a variant of type attribute lookup
that returns `_PyStackRef` instead of `PyObject*`. This allows returning
deferred references in the free-threaded build, reducing reference count
contention when accessing type attributes.

This significantly improves scaling of namedtuple instantiation across
multiple threads.

* Add blurb

* Rename PyObject_GetAttrStackRef to _PyObject_GetAttrStackRef

* Apply suggestion from @vstinner

Co-authored-by: Victor Stinner <vstinner@python.org>

* Apply suggestion from @vstinner

Co-authored-by: Victor Stinner <vstinner@python.org>

* format

* Update Include/internal/pycore_function.h

Co-authored-by: Victor Stinner <vstinner@python.org>

---------

Co-authored-by: Victor Stinner <vstinner@python.org>
2026-02-06 09:43:05 -05:00
Sam Gross 93b27e7f6d gh-139103: use METH_FASTCALL for tp_new_wrapper (#144406) 2026-02-03 16:02:06 +05:30
15c9f2491d gh-115231: Fill __module__ for built-in staticmethods (#115232)
Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
Co-authored-by: Victor Stinner <vstinner@python.org>
2026-02-02 12:34:02 +01:00
Manuel Jacob 03e6457096 Remove outdated comment about excess_args warning in object.__init__ (#143669)
The code emitting a warning was removed in 96384b93aa.
2026-01-11 10:27:11 +03:00
Serhiy Storchaka 4d21297d28 gh-41779: Allow defining any __slots__ for a class derived from tuple (GH-141763) 2026-01-06 11:36:00 +02:00
Dino Viehland da8199f884 gh-123241: Don't modify ref count during visitation (GH-142232) 2025-12-11 09:54:29 +01:00
Uwe L. Korn f6f456f950 gh-142038: Expand guard for types_world_is_stopped() to fix debug builds without assertions (#142039) 2025-12-03 15:24:17 +01:00
Serhiy Storchaka 4bcab461c2 gh-41779: Allow defining the __dict__ and __weakref__ __slots__ for any class (GH-141755) 2025-11-19 17:11:37 +00:00