summaryrefslogtreecommitdiffstats
path: root/Objects
Commit message (Collapse)AuthorAgeFilesLines
* gh-112532: Improve mimalloc page visiting (#114133)Sam Gross2024-01-222-34/+130
| | | | | | | | | | | | | | | This adds support for visiting abandoned pages in mimalloc and improves the performance of the page visiting code. Abandoned pages contain memory blocks from threads that have exited. At some point, they may be later reclaimed by other threads. We still need to visit those pages in the free-threaded GC because they contain live objects. This also reduces the overhead of visiting mimalloc pages: * Special cases for full, empty, and pages containing only a single block. * Fix free_map to use one bit instead of one byte per block. * Use fast integer division by a constant algorithm when computing block offset from block size and index.
* gh-112529: Use GC heaps for GC allocations in free-threaded builds (gh-114157)Sam Gross2024-01-201-1/+2
| | | | | | | | | | * gh-112529: Use GC heaps for GC allocations in free-threaded builds The free-threaded build's garbage collector implementation will need to find GC objects by traversing mimalloc heaps. This hooks up the allocation calls with the correct heaps by using a thread-local "current_obj_heap" variable. * Refactor out setting heap based on type
* gh-111968: Fix --without-freelists build (gh-114270)Donghee Na2024-01-181-5/+14
|
* gh-112087: Remove duplicated critical_section (gh-114268)Donghee Na2024-01-181-6/+3
|
* gh-111968: Use per-thread freelists for generator in free-threading (gh-114189)Donghee Na2024-01-181-40/+24
|
* gh-114050: Fix crash when more than two arguments are passed to int() ↵kcatss2024-01-181-1/+1
| | | | | (GH-114067) Co-authored-by: Kirill Podoprigora <kirill.bast9@mail.ru>
* gh-106293: Fix typos in Objects/object_layout.md (#106294)Mano Sriram2024-01-161-3/+3
| | | Co-authored-by: Terry Jan Reedy <tjreedy@udel.edu>
* gh-112529: Track if debug allocator is used as underlying allocator (#113747)Sam Gross2024-01-161-6/+15
| | | | | | | | | | | | | | | * gh-112529: Track if debug allocator is used as underlying allocator The GC implementation for free-threaded builds will need to accurately detect if the debug allocator is used because it affects the offset of the Python object from the beginning of the memory allocation. The current implementation of `_PyMem_DebugEnabled` only considers if the debug allocator is the outer-most allocator; it doesn't handle the case of "hooks" like tracemalloc being used on top of the debug allocator. This change enables more accurate detection of the debug allocator by tracking when debug hooks are enabled. * Simplify _PyMem_DebugEnabled
* gh-112087: Update list impl to be thread-safe with manual CS (gh-113863)Donghee Na2024-01-162-18/+91
|
* gh-111968: Use per-thread slice_cache in free-threading (gh-113972)Donghee Na2024-01-151-11/+15
|
* gh-112532: Fix memory block count for free-threaded build (gh-113995)Sam Gross2024-01-151-18/+27
| | | | | | | | This fixes `_PyInterpreterState_GetAllocatedBlocks()` and `_Py_GetGlobalAllocatedBlocks()` in the free-threaded builds. The gh-113263 change that introduced multiple mimalloc heaps per-thread broke the logic for counting the number of allocated blocks. For subtle reasons, this led to reported reference count leaks in the refleaks buildbots.
* gh-109598: make PyComplex_RealAsDouble/ImagAsDouble use __complex__ (GH-109647)Sergey B Kirpichev2024-01-151-4/+29
| | | | | | | | | | `PyComplex_RealAsDouble()`/`PyComplex_ImagAsDouble` now try to convert an object to a `complex` instance using its `__complex__()` method before falling back to the ``__float__()`` method. PyComplex_ImagAsDouble() also will not silently return 0.0 for non-complex types anymore. Instead we try to call PyFloat_AsDouble() and return 0.0 only if this call is successful.
* gh-111968: Explicit handling for finalized freelist (gh-113929)Donghee Na2024-01-122-19/+7
|
* gh-111968: Use per-thread freelists for tuple in free-threading (gh-113921)Donghee Na2024-01-111-22/+15
|
* gh-112640: Add `kwdefaults` parameter to `types.FunctionType.__new__` (#112641)Nikita Sobolev2024-01-112-13/+35
|
* gh-111968: Unify naming scheme for freelist (gh-113919)Donghee Na2024-01-101-2/+2
|
* gh-113753: Clear finalized bit when putting PyAsyncGenASend back into free ↵Sam Gross2024-01-101-0/+2
| | | | list (#113754)
* gh-111968: Use per-thread freelists for float in free-threading (gh-113886)Donghee Na2024-01-101-27/+20
|
* gh-111968: Introduce _PyFreeListState and _PyFreeListState_GET API (gh-113584)Donghee Na2024-01-091-11/+11
|
* gh-112087: Update list.{pop,clear,reverse,remove} to use CS (gh-113764)Donghee Na2024-01-092-9/+46
|
* gh-112808: Fix mimalloc build on Solaris (#112809)Jakub Kulík2024-01-081-1/+1
|
* gh-112806: Remove unused function warnings during mimalloc build on Solaris ↵Jakub Kulík2024-01-081-2/+2
| | | | (#112807)
* gh-113750: Fix object resurrection in free-threaded builds (gh-113751)Sam Gross2024-01-061-3/+12
| | | | | | | | | gh-113750: Fix object resurrection on free-threaded builds This avoids the undesired re-initializing of fields like `ob_gc_bits`, `ob_mutex`, and `ob_tid` when an object is resurrected due to its finalizer being called. This change has no effect on the default (with GIL) build.
* gh-112532: Tag mimalloc heaps and pages (#113742)Sam Gross2024-01-054-13/+30
| | | | | | | | | | | | | | | | | | | | | * gh-112532: Tag mimalloc heaps and pages Mimalloc pages are data structures that contain contiguous allocations of the same block size. Note that they are distinct from operating system pages. Mimalloc pages are contained in segments. When a thread exits, it abandons any segments and contained pages that have live allocations. These segments and pages may be later reclaimed by another thread. To support GC and certain thread-safety guarantees in free-threaded builds, we want pages to only be reclaimed by the corresponding heap in the claimant thread. For example, we want pages containing GC objects to only be claimed by GC heaps. This allows heaps and pages to be tagged with an integer tag that is used to ensure that abandoned pages are only claimed by heaps with the same tag. Heaps can be initialized with a tag (0-15); any page allocated by that heap copies the corresponding tag. * Fix conversion warning
* gh-112532: Isolate abandoned segments by interpreter (#113717)Sam Gross2024-01-042-58/+44
| | | | | | | | | | | | | | | * gh-112532: Isolate abandoned segments by interpreter Mimalloc segments are data structures that contain memory allocations along with metadata. Each segment is "owned" by a thread. When a thread exits, it abandons its segments to a global pool to be later reclaimed by other threads. This changes the pool to be per-interpreter instead of process-wide. This will be important for when we use mimalloc to find GC objects in the `--disable-gil` builds. We want heaps to only store Python objects from a single interpreter. Absent this change, the abandoning and reclaiming process could break this isolation. * Add missing '&_mi_abandoned_default' to 'tld_empty'
* Document the `co_lines` method on code objects (#113682)Alex Waygood2024-01-031-1/+1
| | | Co-authored-by: Hugo van Kemenade <hugovk@users.noreply.github.com>
* gh-111178: Avoid calling functions from incompatible pointer types in ↵Christopher Chavez2024-01-021-100/+126
| | | | | dictobject.c (#112892) Fix undefined behavior warnings (UBSan -fsanitize=function).
* gh-111178: Avoid calling functions from incompatible pointer types in ↵Christopher Chavez2024-01-021-106/+147
| | | | | | | | | | descrobject.c (GH-112861) Fix undefined behavior warnings (UBSan -fsanitize=function), for example: Python/generated_cases.c.h:3315:13: runtime error: call to function mappingproxy_dealloc through pointer to incorrect function type 'void (*)(struct _object *)' descrobject.c:1160: note: mappingproxy_dealloc defined here SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior Python/generated_cases.c.h:3315:13 in
* gh-111178: Avoid calling functions from incompatible pointer types in ↵Christopher Chavez2024-01-021-72/+92
| | | | | | | | | | listobject.c (GH-112820) Fix undefined behavior warnings (UBSan -fsanitize=function), for example: Objects/object.c:674:11: runtime error: call to function list_repr through pointer to incorrect function type 'struct _object *(*)(struct _object *)' listobject.c:382: note: list_repr defined here SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior Objects/object.c:674:11 in
* gh-112532: Use separate mimalloc heaps for GC objects (gh-113263)Sam Gross2023-12-263-22/+67
| | | | | | | | | | | | | | | | | | | | | | | | | | * gh-112532: Use separate mimalloc heaps for GC objects In `--disable-gil` builds, we now use four separate heaps in anticipation of using mimalloc to find GC objects when the GIL is disabled. To support this, we also make a few changes to mimalloc: * `mi_heap_t` and `mi_tld_t` initialization is split from allocation. This allows us to have a `mi_tld_t` per-`PyThreadState`, which is important to keep interpreter isolation, since the same OS thread may run in multiple interpreters (using different PyThreadStates.) * Heap abandoning (mi_heap_collect_ex) can now be called from a different thread than the one that created the heap. This is necessary because we may clear and delete the containing PyThreadStates from a different thread during finalization and after fork(). * Use enum instead of defines and guard mimalloc includes. * The enum typedef will be convenient for future PRs that use the type. * Guarding the mimalloc includes allows us to unconditionally include pycore_mimalloc.h from other header files that rely on things like `struct _mimalloc_thread_state`. * Only define _mimalloc_thread_state in Py_GIL_DISABLED builds
* gh-111971: Make _PyUnicode_FromId thread-safe in --disable-gil (gh-113489)Donghee Na2023-12-261-3/+7
|
* gh-113212: Improve error message & document zero-arg super inside nested ↵Yan Yanchii2023-12-221-3/+16
| | | | functions and generator expressions (GH-113307)
* gh-112027: Don't print mimalloc warning after mmap() call (gh-113372)Sam Gross2023-12-221-2/+2
| | | | | | | gh-112027: Don't print mimalloc warning after mmap This changes the warning to a "verbose"-level message in prim.c. The address passed to mmap is only a hint -- it's normal for mmap() to sometimes not respect the hint and return a different address.
* gh-113157 gh-89519: Fix method descriptors (gh-113233)Raymond Hettinger2023-12-211-0/+8
| | | Restore behaviors before classmethod descriptor chaining was introduced.
* gh-95754: Better AttributeError on partially initialised module (#112577)Shantanu2023-12-211-2/+22
| | | Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
* gh-110383: Improve accuracy of str.split() and str.rsplit() docstrings (#113355)Erlend E. Aasland2023-12-212-5/+9
| | | | Clarify split direction in the docstring body, instead of in the 'maxsplit' param docstring.
* gh-111375: Use `NULL` rather than `None` in the exception stack to indicate ↵Carey Metcalfe2023-12-211-1/+1
| | | | that an exception was handled (#113302)
* gh-111178: Make slot functions in typeobject.c have compatible types (GH-112752)Christopher Chavez2023-12-202-20/+35
|
* gh-112532: Require mimalloc in `--disable-gil` builds (gh-112883)Sam Gross2023-12-121-2/+13
|
* gh-111178: Avoid calling functions from incompatible pointer types in ↵Christopher Chavez2023-12-111-61/+90
| | | | | | | | | | | | | | | | | | | | | | | memoryobject.c (GH-112863) * Make memory_clear() compatible with inquiry * Make memory_traverse() compatible with traverseproc * Make memory_dealloc() compatible with destructor * Make memory_repr() compatible with reprfunc * Make memory_hash() compatible with hashfunc * Make memoryiter_next() compatible with iternextfunc * Make memoryiter_traverse() compatible with traverseproc * Make memoryiter_dealloc() compatible with destructor * Make several functions compatible with getter * Make a few functions compatible with getter * Make memory_item() compatible with ssizeargfunc * Make memory_subscript() compatible with binaryfunc * Make memory_length() compatible with lenfunc * Make memory_ass_sub() compatible with objobjargproc * Make memory_releasebuf() compatible with releasebufferproc * Make memory_getbuf() compatible with getbufferproc * Make mbuf_clear() compatible with inquiry * Make mbuf_traverse() compatible with traverseproc * Make mbuf_dealloc() compatible with destructor
* gh-111924: Use PyMutex for Runtime-global Locks. (gh-112207)Sam Gross2023-12-072-47/+18
| | | | | This replaces some usages of PyThread_type_lock with PyMutex, which does not require memory allocation to initialize. This simplifies some of the runtime initialization and is also one step towards avoiding changing the default raw memory allocator during initialize/finalization, which can be non-thread-safe in some circumstances.
* gh-112125: Fix None.__ne__(None) returning NotImplemented instead of False ↵andrewluotechnologies2023-12-072-1/+7
| | | | (#112504)
* gh-112660: Do not clear arbitrary errors on import (GH-112661)Serhiy Storchaka2023-12-071-32/+25
| | | | | Previously arbitrary errors could be cleared during formatting error messages for ImportError or AttributeError for modules. Now all unexpected errors are reported.
* Minor refactoring of Object/abstract.c (UNARY_FUNC macro and more cases for ↵Sergey B Kirpichev2023-12-051-90/+25
| | | | | | | BINARY_FUNC) (GH-112145) * Use BINARY_FUNC macro for some remaining ops * Add UNARY_FUNC macro to define unary PyNumber_* functions
* gh-112625: Protect bytearray from being freed by misbehaving iterator inside ↵chilaxan2023-12-041-1/+4
| | | | bytearray.join (GH-112626)
* gh-111058: Change coro.cr_frame/gen.gi_frame to be None for a closed ↵Irit Katriel2023-12-011-1/+1
| | | | coroutine/generator. (#112428)
* gh-111972: Make Unicode name C APIcapsule initialization thread-safe (#112249)Kirill Podoprigora2023-11-301-11/+21
|
* gh-76785: Add _PyType_GetModuleName() to the Internal C-API (gh-112323)Eric Snow2023-11-221-0/+6
| | | The new function corresponds to the existing (public) PyType_GetName() and PyType_GetQualName().
* gh-111863: Rename `Py_NOGIL` to `Py_GIL_DISABLED` (#111864)Hugo van Kemenade2023-11-201-3/+3
| | | Rename Py_NOGIL to Py_GIL_DISABLED
* gh-112266: Remove `(if defined)` part from `__dict__` and `__weakref__` ↵Nikita Sobolev2023-11-191-4/+4
| | | | docstrings (#112268)