summaryrefslogtreecommitdiffstats
path: root/Objects/dictobject.c
Commit message (Collapse)AuthorAgeFilesLines
* gh-104717: Add comment about manual loop unrolling (gh-104718)Dong-hee Na2023-05-211-0/+1
|
* gh-104252: Immortalize Py_EMPTY_KEYS (gh-104253)Eric Snow2023-05-101-11/+21
| | | This was missed in gh-19474. It matters for with a per-interpreter GIL since PyDictKeysObject.dk_refcnt breaks isolation and leads to races.
* gh-102304: Move the Total Refcount to PyInterpreterState (gh-102545)Eric Snow2023-03-211-5/+5
| | | | | 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-102701: Fix overflow in dictobject.c (GH-102750)Inada Naoki2023-03-171-1/+1
|
* gh-100227: Move dict_state.global_version to PyInterpreterState (gh-102338)Eric Snow2023-03-091-90/+146
| | | https://github.com/python/cpython/issues/100227
* gh-100227: Move next_keys_version to PyInterpreterState (gh-102335)Eric Snow2023-03-091-3/+4
| | | https://github.com/python/cpython/issues/100227
* gh-102304: Consolidate Direct Usage of _Py_RefTotal (gh-102514)Eric Snow2023-03-081-5/+5
| | | | | 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-102192: Replace PyErr_Fetch/Restore etc by more efficient alternatives ↵Irit Katriel2023-03-081-1/+1
| | | | (in Objects/) (#102218)
* gh-102381: don't call watcher callback with dead object (#102382)Carl Meyer2023-03-081-3/+31
| | | Co-authored-by: T. Wouters <thomas@python.org>
* GH-101578: Normalize the current exception (GH-101607)Mark Shannon2023-02-081-3/+3
| | | | | | | | | | * Make sure that the current exception is always normalized. * Remove redundant type and traceback fields for the current exception. * Add new API functions: PyErr_GetRaisedException, PyErr_SetRaisedException * Add new API functions: PyException_GetArgs, PyException_SetArgs
* gh-99845: Change _PyDict_KeysSize() return type to size_t (#99848)Victor Stinner2022-11-291-31/+26
| | | | | | | | * Change _PyDict_KeysSize() and shared_keys_usable_size() return type from signed (Py_ssize_t) to unsigned (size_t) type. * new_values() argument type is now unsigned (size_t). * init_inline_values() now uses size_t rather than int for the 'i' iterator variable. * type.__sizeof__() implementation now uses unsigned (size_t) type.
* gh-81057: Move the global Dict-Related Versions to _PyRuntimeState (gh-99497)Eric Snow2022-11-161-14/+7
| | | | | We also move the global func version. https://github.com/python/cpython/issues/81057
* gh-99300: Replace Py_INCREF() with Py_NewRef() (#99530)Victor Stinner2022-11-161-6/+3
| | | | Replace Py_INCREF() and Py_XINCREF() using a cast with Py_NewRef() and Py_XNewRef().
* gh-99300: Use Py_NewRef() in Objects/dictobject.c (#99333)Victor Stinner2022-11-101-92/+48
| | | | Replace Py_INCREF() and Py_XINCREF() with Py_NewRef() and Py_XNewRef() in Objects/dictobject.c.
* gh-91052: Add PyDict_Unwatch for unwatching a dictionary (#98055)Carl Meyer2022-10-081-11/+30
|
* GH-91052: Add C API for watching dictionaries (GH-31787)Carl Meyer2022-10-071-15/+104
|
* Fix minor comment typo in dictobject.c (GH-96960)Samuel2022-09-201-1/+1
| | | | | Fix a minor comment typo in the Objects/dictobject.c file. Automerge-Triggered-By: GH:methane
* gh-96364: Fix text signatures of `__getitem__` for `list` and `dict` (GH-96365)Nikita Sobolev2022-09-091-1/+2
|
* Remove dead code in _PyDict_GetItemHint and rename to _PyDict_LookupIndex ↵Matthias Görgens2022-08-181-41/+3
| | | | (GH-95948)
* GH-95245: Store object values and dict pointers in single tagged pointer. ↵Mark Shannon2022-08-011-71/+90
| | | | (GH-95278)
* GH-92678: Expose managed dict clear and visit functions (#95246)Mark Shannon2022-07-251-0/+29
|
* bpo-43857: Improve the AttributeError message when deleting a missing ↵Géry Ogam2022-05-051-1/+3
| | | | | attribute (#25424) Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
* Add more stats for freelist use and allocations. (GH-92211)Mark Shannon2022-05-031-0/+5
|
* gh-91320: Use _PyCFunction_CAST() (#92251)Victor Stinner2022-05-031-6/+6
| | | | | | | | | | Replace "(PyCFunction)(void(*)(void))func" cast with _PyCFunction_CAST(func). Change generated by the command: sed -i -e \ 's!(PyCFunction)(void(\*)(void)) *\([A-Za-z0-9_]\+\)!_PyCFunction_CAST(\1)!g' \ $(find -name "*.c")
* bpo-47164: Add _PyASCIIObject_CAST() macro (GH-32191)Victor Stinner2022-03-311-1/+1
| | | | | | | | | | | | Add macros to cast objects to PyASCIIObject*, PyCompactUnicodeObject* and PyUnicodeObject*: _PyASCIIObject_CAST(), _PyCompactUnicodeObject_CAST() and _PyUnicodeObject_CAST(). Using these new macros make the code more readable and check their argument with: assert(PyUnicode_Check(op)). Remove redundant assert(PyUnicode_Check(op)) in macros using directly or indirectly these new CAST macros. Replacing existing casts with these macros.
* bpo-46903: Handle str-subclasses in virtual instance dictionaries. (GH-31658)Mark Shannon2022-03-041-10/+18
|
* dict: Fix refleak (GH-31650)Inada Naoki2022-03-031-4/+8
|
* dict: Internal cleanup (GH-31641)Inada Naoki2022-03-021-66/+44
| | | | * Make empty_key from split table to combined table. * Use unicode_get_hash() when possible.
* bpo-46845: Reduce dict size when all keys are Unicode (GH-31564)Inada Naoki2022-03-011-405/+778
|
* bpo-45459: C API uses type names rather than structure names (GH-31528)Victor Stinner2022-02-241-3/+3
| | | | Thanks to the new pytypedefs.h, it becomes to use type names like PyObject rather like structure names like "struct _object".
* dict: Add dk_log2_index_bytes (GH-31439)Inada Naoki2022-02-221-23/+27
|
* dict: Use DK_LOG_SIZE in hot loop. (GH-31405)Inada Naoki2022-02-191-12/+12
| | | DK_LOG_SIZE(key) < 8 is faster than DK_SIZE(key) <= 0xff, at least on GCC.
* bpo-46541: Replace core use of _Py_IDENTIFIER() with statically initialized ↵Eric Snow2022-02-081-17/+23
| | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-46675: Allow object value arrays and split key dictionaries larger than ↵Mark Shannon2022-02-081-39/+59
| | | | 16 (GH-31191)
* bpo-46670: Remove unused macros in the Objects directory (GH-31193)Victor Stinner2022-02-071-1/+0
|
* bpo-46072: Add some object layout and allocation stats (GH-31051)Mark Shannon2022-02-011-0/+12
|
* bpo-46417: Use _PyType_CAST() in Objects directory (GH-30764)Victor Stinner2022-01-211-2/+1
|
* bpo-45947: Place dict and values pointer at fixed (negative) offset just ↵Mark Shannon2021-12-071-33/+53
| | | | | | | | | | | | | | | | | | | before GC header. (GH-29879) * Place __dict__ immediately before GC header for plain Python objects. * Fix up lazy dict creation logic to use managed dict pointers. * Manage values pointer, placing them directly before managed dict pointers. * Convert hint-based load/store attr specialization target managed dict classes. * Specialize LOAD_METHOD for managed dict objects. * Remove unsafe _PyObject_GC_Calloc function. * Remove unsafe _PyObject_GC_Malloc() function. * Add comment explaning use of Py_TPFLAGS_MANAGED_DICT.
* bpo-45609: Specialize STORE_SUBSCR (GH-29242)Dennis Sweeney2021-11-191-21/+47
| | | | | * Specialize STORE_SUBSCR for list[int], and dict[object] * Adds _PyDict_SetItem_Take2 which consumes references to the key and values.
* bpo-45522: Allow to disable freelists on build time (GH-29056)Christian Heimes2021-10-211-4/+23
| | | | | | | | 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-45340: Don't create object dictionaries unless actually needed (GH-28802)Mark Shannon2021-10-131-145/+289
| | | | | | | | | | | | | | * Never change types' cached keys. It could invalidate inline attribute objects. * Lazily create object dictionaries. * Update specialization of LOAD/STORE_ATTR. * Don't update shared keys version for deletion of value. * Update gdb support to handle instance values. * Rename SPLIT_KEYS opcodes to INSTANCE_VALUE.
* bpo-45439: Move _PyObject_CallNoArgs() to pycore_call.h (GH-28895)Victor Stinner2021-10-121-7/+8
| | | | | | | * Move _PyObject_CallNoArgs() to pycore_call.h (internal C API). * _ssl, _sqlite and _testcapi extensions now call the public PyObject_CallNoArgs() function, rather than _PyObject_CallNoArgs(). * _lsprof extension is now built with Py_BUILD_CORE_MODULE macro defined to get access to internal _PyObject_CallNoArgs().
* bpo-45439: Rename _PyObject_CallNoArg() to _PyObject_CallNoArgs() (GH-28891)Victor Stinner2021-10-111-1/+1
| | | | | Fix typo in the private _PyObject_CallNoArg() function name: rename it to _PyObject_CallNoArgs() to be consistent with the public function PyObject_CallNoArgs().
* bpo-40116: Add insertion order bit-vector to dict values to allow dicts to ↵Mark Shannon2021-10-061-130/+151
| | | | share keys more freely. (GH-28520)
* 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-45219: Factor dictkey indexing (GH-28389)Mark Shannon2021-09-171-42/+84
|
* bpo-44826: Specialize STORE_ATTR (GH-27590)Mark Shannon2021-08-091-3/+1
| | | | | | | * Generalize cache names for LOAD_ATTR to allow store and delete specializations. * Factor out specialization of attribute dictionary access. * Specialize STORE_ATTR.
* bpo-44821: Eagerly assign __dict__ for new objects. (GH-27589)Mark Shannon2021-08-041-3/+28
|
* bpo-44206: Make sure that dict-keys's version is set to zero when value is ↵Mark Shannon2021-08-021-0/+1
| | | | popped (GH-27542)
* bpo-44531: Add _PyType_AllocNoTrack() function (GH-26947)Victor Stinner2021-07-011-11/+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().