summaryrefslogtreecommitdiffstats
path: root/Objects/tupleobject.c
Commit message (Collapse)AuthorAgeFilesLines
* gh-111178: Fix function signatures in tupleobject.c (#124804)Victor Stinner2024-10-021-58/+64
|
* gh-111178: fix some USAN failures - mismatched function pointers (GH-123004)Bénédikt Tran2024-09-271-2/+3
|
* gh-123990: Good bye WITH_FREELISTS macro (gh-124358)Donghee Na2024-09-241-2/+0
|
* gh-100240: Use a consistent implementation for freelists (#121934)Sam Gross2024-07-221-100/+17
| | | | | | | | This combines and updates our freelist handling to use a consistent implementation. Objects in the freelist are linked together using the first word of memory block. If configured with freelists disabled, these operations are essentially no-ops.
* GH-121439: Allow PyTupleObjects with an ob_size of 20 in the free_list to be ↵satori19952024-07-101-1/+1
| | | | reused (gh-121428)
* gh-117139: Add _PyTuple_FromStackRefSteal and use it (#121244)Sam Gross2024-07-021-0/+21
| | | Avoids the extra conversion from stack refs to PyObjects.
* gh-117439: Make refleak checking thread-safe without the GIL (#117469)Sam Gross2024-04-081-1/+1
| | | | | This keeps track of the per-thread total reference count operations in PyThreadState in the free-threaded builds. The count is merged into the interpreter's total when the thread exits.
* gh-116381: Remove bad specializations, add fail stats (GH-116464)Ken Jin2024-03-071-3/+3
| | | * Remove bad specializations, add fail stats
* gh-116381: Specialize CONTAINS_OP (GH-116385)Ken Jin2024-03-061-3/+3
| | | | | | | | | | | * Specialize CONTAINS_OP * 📜🤖 Added by blurb_it. * Add PyAPI_FUNC for JIT --------- Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
* gh-111968: Split _Py_dictkeys_freelist out of _Py_dict_freelist (gh-115505)Donghee Na2024-02-161-6/+6
|
* gh-111968: Rename freelist related struct names to Eric's suggestion (gh-115329)Donghee Na2024-02-141-21/+21
|
* gh-111968: Refactor _PyXXX_Fini to integrate with _PyObject_ClearFreeLists ↵Donghee Na2024-02-101-5/+0
| | | | (gh-114899)
* gh-111968: Unify freelist naming schema to Eric's suggestion (gh-114581)Donghee Na2024-01-261-1/+1
|
* gh-111968: Use per-thread freelists for tuple in free-threading (gh-113921)Donghee Na2024-01-111-22/+15
|
* gh-106320: Remove private _PyEval function (#108433)Victor Stinner2023-08-241-0/+1
| | | | | | | | | | | | | | Move private _PyEval functions to the internal C API (pycore_ceval.h): * _PyEval_GetBuiltin() * _PyEval_GetBuiltinId() * _PyEval_GetSwitchInterval() * _PyEval_MakePendingCalls() * _PyEval_SetProfile() * _PyEval_SetSwitchInterval() * _PyEval_SetTrace() No longer export most of these functions.
* GH-84436: Skip refcounting for known immortals (GH-107605)Brandt Bucher2023-08-041-1/+1
|
* gh-106320: Remove private _PyObject C API (#107147)Victor Stinner2023-07-231-1/+1
| | | | | | | | | | | | | | | | Move private debug _PyObject functions to the internal C API (pycore_object.h): * _PyDebugAllocatorStats() * _PyObject_CheckConsistency() * _PyObject_DebugTypeStats() * _PyObject_IsFreed() No longer export most of these functions, except of _PyObject_IsFreed(). Move test functions using _PyObject_IsFreed() from _testcapi to _testinternalcapi. check_pyobject_is_freed() test no longer catch _testcapi.error: the tested function cannot raise _testcapi.error.
* gh-106320: Create pycore_modsupport.h header file (#106355)Victor Stinner2023-07-031-0/+1
| | | | | | | | | | Remove the following functions from the C API, move them to the internal C API: add a new pycore_modsupport.h internal header file: * PyModule_CreateInitialized() * _PyArg_NoKwnames() * _Py_VaBuildStack() No longer export these functions.
* gh-94673: Ensure Builtin Static Types are Readied Properly (gh-103940)Eric Snow2023-04-271-18/+0
| | | There were cases where we do unnecessary work for builtin static types. This also simplifies some work necessary for a per-interpreter GIL.
* gh-102304: Move the Total Refcount to PyInterpreterState (gh-102545)Eric Snow2023-03-211-1/+1
| | | | | Moving it valuable with a per-interpreter GIL. However, it is also useful without one, since it allows us to identify refleaks within a single interpreter or where references are escaping an interpreter. This becomes more important as we move the obmalloc state to PyInterpreterState. https://github.com/python/cpython/issues/102304
* gh-102304: Consolidate Direct Usage of _Py_RefTotal (gh-102514)Eric Snow2023-03-081-5/+4
| | | | | This simplifies further changes to _Py_RefTotal (e.g. make it atomic or move it to PyInterpreterState). https://github.com/python/cpython/issues/102304
* gh-101765: Fix SystemError / segmentation fault in iter `__reduce__` when ↵Ionite2023-02-241-3/+8
| | | | internal access of `builtins.__dict__` exhausts the iterator (#101769)
* GH-84783: Make the slice object hashable (GH-101264)Furkan Onder2023-02-191-1/+1
|
* GH-100110: Specialize FOR_ITER for tuples (GH-100109)Ken Jin2022-12-091-14/+9
| | | * Specialize FOR_ITER for tuples
* gh-99300: Use Py_NewRef() in Objects/ directory (#99351)Victor Stinner2022-11-101-30/+15
| | | | Replace Py_INCREF() and Py_XINCREF() with Py_NewRef() and Py_XNewRef() in C files of the Objects/ directory.
* gh-91247: Use memcpy for list and tuple repeat (#91482)Pieter Eendebak2022-07-261-23/+18
| | | | | | | * Add _Py_memory_repeat function to pycore_list * Add _Py_RefcntAdd function to pycore_object * Use the new functions in tuplerepeat, list_repeat, and list_inplace_repeat
* Add more stats for freelist use and allocations. (GH-92211)Mark Shannon2022-05-031-0/+2
|
* gh-90667: Add specializations of Py_DECREF when types are known (GH-30872)Dennis Sweeney2022-04-191-2/+1
|
* bpo-46753: Add the empty tuple to the _PyRuntimeState.global_objects. (gh-31345)Eric Snow2022-02-281-174/+164
| | | https://bugs.python.org/issue46753
* bpo-46541: Replace core use of _Py_IDENTIFIER() with statically initialized ↵Eric Snow2022-02-081-3/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | global objects. (gh-30928) We're no longer using _Py_IDENTIFIER() (or _Py_static_string()) in any core CPython code. It is still used in a number of non-builtin stdlib modules. The replacement is: PyUnicodeObject (not pointer) fields under _PyRuntimeState, statically initialized as part of _PyRuntime. A new _Py_GET_GLOBAL_IDENTIFIER() macro facilitates lookup of the fields (along with _Py_GET_GLOBAL_STRING() for non-identifier strings). https://bugs.python.org/issue46541#msg411799 explains the rationale for this change. The core of the change is in: * (new) Include/internal/pycore_global_strings.h - the declarations for the global strings, along with the macros * Include/internal/pycore_runtime_init.h - added the static initializers for the global strings * Include/internal/pycore_global_objects.h - where the struct in pycore_global_strings.h is hooked into _PyRuntimeState * Tools/scripts/generate_global_objects.py - added generation of the global string declarations and static initializers I've also added a --check flag to generate_global_objects.py (along with make check-global-objects) to check for unused global strings. That check is added to the PR CI config. The remainder of this change updates the core code to use _Py_GET_GLOBAL_IDENTIFIER() instead of _Py_IDENTIFIER() and the related _Py*Id functions (likewise for _Py_GET_GLOBAL_STRING() instead of _Py_static_string()). This includes adding a few functions where there wasn't already an alternative to _Py*Id(), replacing the _Py_Identifier * parameter with PyObject *. The following are not changed (yet): * stop using _Py_IDENTIFIER() in the stdlib modules * (maybe) get rid of _Py_IDENTIFIER(), etc. entirely -- this may not be doable as at least one package on PyPI using this (private) API * (maybe) intern the strings during runtime init https://bugs.python.org/issue46541
* bpo-46417: Use _PyType_CAST() in Objects directory (GH-30764)Victor Stinner2022-01-211-1/+1
|
* bpo-46235: Do all ref-counting at once during list/tuple multiplication ↵Dennis Sweeney2022-01-081-9/+26
| | | | | | | | | | (GH-30346) When multiplying lists and tuples by `n`, increment each element's refcount, by `n`, just once. Saves `n-1` increments per element, and allows for a leaner & faster copying loop. Code by sweeneyde (Dennis Sweeney).
* bpo-46008: Make runtime-global object/type lifecycle functions and state ↵Eric Snow2021-12-091-1/+20
| | | | | | | | | | | | consistent. (gh-29998) This change is strictly renames and moving code around. It helps in the following ways: * ensures type-related init functions focus strictly on one of the three aspects (state, objects, types) * passes in PyInterpreterState * to all those functions, simplifying work on moving types/objects/state to the interpreter * consistent naming conventions help make what's going on more clear * keeping API related to a type in the corresponding header file makes it more obvious where to look for it https://bugs.python.org/issue46008
* bpo-45522: Allow to disable freelists on build time (GH-29056)Christian Heimes2021-10-211-1/+2
| | | | | | | | Freelists for object structs can now be disabled. A new ``configure`` option ``--without-freelists`` can be used to disable all freelists except empty tuple singleton. Internal Py*_MAXFREELIST macros can now be defined as 0 without causing compiler warnings and segfaults. Signed-off-by: Christian Heimes <christian@python.org>
* bpo-45256: Avoid C calls for most Python to Python calls. (GH-28937)Mark Shannon2021-10-181-1/+3
| | | | | | * Avoid making C calls for most calls to Python functions. * Change initialize_locals(steal=true) and _PyTuple_FromArraySteal to consume the argument references regardless of whether they succeed or fail.
* bpo-45256: Remove the usage of the C stack in Python to Python calls (GH-28488)Pablo Galindo Salgado2021-10-091-0/+20
| | | | Ths commit inlines calls to Python functions in the eval loop and steals all the arguments in the call from the caller for performance.
* bpo-45061: Detect refcount bug on empty tuple singleton (GH-28503)Victor Stinner2021-09-211-1/+18
| | | | | | Detect refcount bugs in C extensions when the empty tuple singleton is destroyed by mistake. Add the _Py_FatalRefcountErrorFunc() function.
* Clean up initialization __class_getitem__ with Py_GenericAlias. (GH-28450)Serhiy Storchaka2021-09-191-1/+1
| | | | | The cast to PyCFunction is redundant. Overuse of redundant casts can hide actual bugs.
* bpo-44531: Add _PyType_AllocNoTrack() function (GH-26947)Victor Stinner2021-07-011-16/+19
| | | | | | | | | | | | Add an internal _PyType_AllocNoTrack() function to allocate an object without tracking it in the GC. Modify dict_new() to use _PyType_AllocNoTrack(): dict subclasses are now only tracked once all PyDictObject members are initialized. Calling _PyObject_GC_UNTRACK() is no longer needed for the dict type. Similar change in tuple_subtype_new() for tuple subclasses. Replace tuple_gc_track() with _PyObject_GC_TRACK().
* bpo-43977: Use tp_flags for collection matching (GH-25723)Mark Shannon2021-04-301-1/+1
| | | | | | | | | | | | | * Add Py_TPFLAGS_SEQUENCE and Py_TPFLAGS_MAPPING, add to all relevant standard builtin classes. * Set relevant flags on collections.abc.Sequence and Mapping. * Use flags in MATCH_SEQUENCE and MATCH_MAPPING opcodes. * Inherit Py_TPFLAGS_SEQUENCE and Py_TPFLAGS_MAPPING. * Add NEWS * Remove interpreter-state map_abc and seq_abc fields.
* bpo-42128: Structural Pattern Matching (PEP 634) (GH-22917)Brandt Bucher2021-02-261-1/+2
| | | | | Co-authored-by: Guido van Rossum <guido@python.org> Co-authored-by: Talin <viridia@gmail.com> Co-authored-by: Pablo Galindo <pablogsal@gmail.com>
* bpo-43268: Pass interp rather than tstate to internal functions (GH-24580)Victor Stinner2021-02-191-7/+7
| | | | | | | | | | | | | | | Pass the current interpreter (interp) rather than the current Python thread state (tstate) to internal functions which only use the interpreter. Modified functions: * _PyXXX_Fini() and _PyXXX_ClearFreeList() functions * _PyEval_SignalAsyncExc(), make_pending_calls() * _PySys_GetObject(), sys_set_object(), sys_set_object_id(), sys_set_object_str() * should_audit(), set_flags_from_config(), make_flags() * _PyAtExit_Call() * init_stdio_encoding() * etc.
* bpo-40521: Always create the empty tuple singleton (GH-21116)Victor Stinner2020-06-241-48/+96
| | | | | | | | | | | Py_InitializeFromConfig() now always creates the empty tuple singleton as soon as possible. Optimize PyTuple_New(0): it no longer has to check if the empty tuple was created or not, it is always creatd. * Add tuple_create_empty_tuple_singleton() function. * Add tuple_get_empty() function. * Remove state parameter of tuple_alloc().
* bpo-40521: Cleanup code of free lists (GH-21082)Victor Stinner2020-06-231-16/+18
| | | Add get_xxx_state() function to factorize duplicated code.
* bpo-40989: PyObject_INIT() becomes an alias to PyObject_Init() (GH-20901)Victor Stinner2020-06-151-1/+1
| | | | | | | | | | | | | | The PyObject_INIT() and PyObject_INIT_VAR() macros become aliases to, respectively, PyObject_Init() and PyObject_InitVar() functions. Rename _PyObject_INIT() and _PyObject_INIT_VAR() static inline functions to, respectively, _PyObject_Init() and _PyObject_InitVar(), and move them to pycore_object.h. Remove their return value: their return type becomes void. The _datetime module is now built with the Py_BUILD_CORE_MODULE macro defined. Remove an outdated comment on _Py_tracemalloc_config.
* bpo-40887: Don't use finalized free lists (GH-20700)Victor Stinner2020-06-081-0/+15
| | | | | | In debug mode, ensure that free lists are no longer used after being finalized. Set numfree to -1 in finalization functions (eg. _PyList_Fini()), and then check that numfree is not equal to -1 before using a free list (e.g list_dealloc()).
* bpo-40521: Make tuple free list per-interpreter (GH-20247)Victor Stinner2020-06-041-58/+53
| | | | | | | | | | Each interpreter now has its own tuple free lists: * Move tuple numfree and free_list arrays into PyInterpreterState. * Define PyTuple_MAXSAVESIZE and PyTuple_MAXFREELIST macros in pycore_interp.h. * Add _Py_tuple_state structure. Pass it explicitly to tuple_alloc(). * Add tstate parameter to _PyTuple_ClearFreeList() * Each interpreter now has its own empty tuple singleton.
* bpo-39573: Convert Py_REFCNT and Py_SIZE to functions (GH-20429)Victor Stinner2020-05-271-1/+1
| | | | | | | | | | | Convert Py_REFCNT() and Py_SIZE() macros to static inline functions. They cannot be used as l-value anymore: use Py_SET_REFCNT() and Py_SET_SIZE() to set an object reference count and size. Replace &Py_SIZE(self) with &((PyVarObject*)self)->ob_size in arraymodule.c. This change is backward incompatible on purpose, to prepare the C API for an opaque PyObject structure.
* bpo-39573: Fix buildbot failure for tupleobject.c (GH-20391)Dong-hee Na2020-05-251-1/+1
|
* bpo-34397: Remove redundant overflow checks in list and tuple ↵Sergey Fedoseev2020-05-251-2/+1
| | | | implementation. (GH-8757)