summaryrefslogtreecommitdiffstats
path: root/Objects/dictobject.c
Commit message (Collapse)AuthorAgeFilesLines
* gh-108511: Add C API functions which do not silently ignore errors (GH-109025)Serhiy Storchaka2023-09-171-4/+3
| | | | | | | | | Add the following functions: * PyObject_HasAttrWithError() * PyObject_HasAttrStringWithError() * PyMapping_HasKeyWithError() * PyMapping_HasKeyStringWithError()
* Add missing `PyDoc_STR` calls (#109393)Nikita Sobolev2023-09-151-1/+1
| | | | | | | | | In files: * Modules/_ctypes/cfield.c * Modules/_struct.c * Objects/dictobject.c * Objects/typevarobject.c * Objects/unionobject.c
* 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-108308: Remove _PyDict_GetItemStringWithError() function (#108426)Victor Stinner2023-08-241-13/+0
| | | | | | | | Remove the internal _PyDict_GetItemStringWithError() function. It can now be replaced with the new public PyDict_ContainsString() and PyDict_GetItemStringRef() functions. getargs.c now now uses a strong reference for current_arg. find_keyword() returns a strong reference.
* gh-108314: Add PyDict_ContainsString() function (#108323)Victor Stinner2023-08-241-0/+12
|
* GH-106485: Create object's dict-values instead of creating __dict__, when we ↵Mark Shannon2023-08-111-3/+1
| | | | can. (GH-107843)
* GH-106485: Handle dict subclasses correctly when dematerializing `__dict__` ↵Mark Shannon2023-08-101-6/+8
| | | | (GH-107837)
* GH-106485: Dematerialize instance dictionaries when possible (GH-106539)Brandt Bucher2023-08-091-0/+33
|
* 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: Move private _PySet API to the internal API (#107041)Victor Stinner2023-07-221-0/+1
| | | | | | | | * Add pycore_setobject.h header file. * Move the following API to the internal C API: * _PySet_Dummy * _PySet_NextEntry() * _PySet_Update()
* gh-106004: Add PyDict_GetItemRef() function (#106005)Victor Stinner2023-07-211-16/+61
| | | | | * Add PyDict_GetItemRef() and PyDict_GetItemStringRef() functions. Add these functions to the stable ABI version 3.13. * Add unit tests on the PyDict C API in test_capi.
* gh-106521: Remove _PyObject_LookupAttr() function (GH-106642)Serhiy Storchaka2023-07-121-1/+1
|
* GH-91095: Specialize calls to normal Python classes. (GH-99331)Mark Shannon2023-06-221-4/+3
|
* 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
|