summaryrefslogtreecommitdiffstats
path: root/Objects/dictobject.c
Commit message (Collapse)AuthorAgeFilesLines
* 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().
* bpo-44337: Port LOAD_ATTR to PEP 659 adaptive interpreter (GH-26595)Mark Shannon2021-06-101-20/+2
| | | | | | | | | | | | | | * Specialize LOAD_ATTR with LOAD_ATTR_SLOT and LOAD_ATTR_SPLIT_KEYS * Move dict-common.h to internal/pycore_dict.h * Add LOAD_ATTR_WITH_HINT specialized opcode. * Quicken in function if loopy * Specialize LOAD_ATTR for module attributes. * Add specialization stats
* Fix MSVC compiler warnings in dictobject.c (GH-26432)Mark Shannon2021-05-291-2/+2
|
* bpo-44206: Fix compiler warnings in dictobject.c (GH-26440)Pablo Galindo2021-05-281-3/+3
|
* bpo-44206: Add a version number to dictionary keys (GH-26333)Mark Shannon2021-05-281-288/+192
| | | | | | | | * Store log2(size) instead of size in dict-keys. * Use enum instead of function pointer to record kind of keys. * Add version number to dict keys.
* bpo-44114: Remove redundant cast. (GH-26098)Inada Naoki2021-05-131-2/+2
|
* bpo-44114: Fix dictkeys_reversed and dictvalues_reversed function signatures ↵Joe Marshall2021-05-131-4/+4
| | | | | | | | (GH-26062) These are passed and called as PyCFunction, however they are defined here without the (ignored) args parameter. This works fine in some C compilers, but fails in webassembly or anything else that has strict function pointer call type checking.
* 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-24275: Don't downgrade unicode-only dicts to mixed on lookups (GH-25186)Hristo Venev2021-04-291-3/+6
|
* bpo-43770: Refactor type_new() function (GH-25325)Victor Stinner2021-04-101-2/+4
| | | | | | | | | | | | * Split type_new() into into many small functions. * Add type_new_ctx structure to pass variables between subfunctions. * Initialize some PyTypeObject and PyHeapTypeObject members earlier in type_new_alloc(). * Rename variables to more specific names. * Add "__weakref__" identifier for type_new_visit_slots(). * Factorize code to convert a method to a classmethod (__init_subclass__ and __class_getitem__). * Add braces to respect PEP 7. * Move variable declarations where the variables are initialized.
* 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-42093: Cleanup _PyDict_GetItemHint() (GH-24582)Victor Stinner2021-02-211-31/+4
| | | | | | * No longer save/restore the current exception. It is no longer used with an exception raised. * No longer clear the current exception on error: it's now up to the caller.
* bpo-43277: Add PySet_CheckExact to the C-API (GH-24598)Pablo Galindo2021-02-201-1/+1
| | | For some mysterious reason we have PySet_Check, PyFrozenSet_Check, PyAnySet_Check, PyAnySet_CheckExact and PyFrozenSet_CheckExact but no PySet_CheckExact.
* bpo-43268: Pass interp rather than tstate to internal functions (GH-24580)Victor Stinner2021-02-191-5/+5
| | | | | | | | | | | | | | | 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-42536: GC track recycled tuples (GH-23623)Brandt Bucher2020-12-051-0/+10
| | | | | | | | | | | | | | | | Several built-in and standard library types now ensure that their internal result tuples are always tracked by the garbage collector: - collections.OrderedDict.items - dict.items - enumerate - functools.reduce - itertools.combinations - itertools.combinations_with_replacement - itertools.permutations - itertools.product - itertools.zip_longest - zip Previously, they could have become untracked by a prior garbage collection.
* bpo-42519: Replace PyObject_MALLOC() with PyObject_Malloc() (GH-23587)Victor Stinner2020-12-011-4/+4
| | | | | | | | | No longer use deprecated aliases to functions: * Replace PyObject_MALLOC() with PyObject_Malloc() * Replace PyObject_REALLOC() with PyObject_Realloc() * Replace PyObject_FREE() with PyObject_Free() * Replace PyObject_Del() with PyObject_Free() * Replace PyObject_DEL() with PyObject_Free()
* bpo-42519: Replace PyMem_MALLOC() with PyMem_Malloc() (GH-23586)Victor Stinner2020-12-011-1/+1
| | | | | | | | | | | No longer use deprecated aliases to functions: * Replace PyMem_MALLOC() with PyMem_Malloc() * Replace PyMem_REALLOC() with PyMem_Realloc() * Replace PyMem_FREE() with PyMem_Free() * Replace PyMem_Del() with PyMem_Free() * Replace PyMem_DEL() with PyMem_Free() Modify also the PyMem_DEL() macro to use directly PyMem_Free().