summaryrefslogtreecommitdiff
path: root/Objects/dictobject.c
Commit message (Collapse)AuthorAgeFilesLines
* 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-041-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().
* bpo-42152: Use PyDict_Contains and PyDict_SetDefault if appropriate. (GH-22986)Serhiy Storchaka2020-10-261-23/+22
| | | | | | | If PyDict_GetItemWithError is only used to check whether the key is in dict, it is better to use PyDict_Contains instead. And if it is used in combination with PyDict_SetItem, PyDict_SetDefault can replace the combination.
* bpo-42006: Stop using PyDict_GetItem, PyDict_GetItemString and ↵Serhiy Storchaka2020-10-261-13/+11
| | | | | | | | | | | _PyDict_GetItemId. (GH-22648) These functions are considered not safe because they suppress all internal errors and can return wrong result. PyDict_GetItemString and _PyDict_GetItemId can also silence current exception in rare cases. Remove no longer used _PyDict_GetItemId. Add _PyDict_ContainsId and rename _PyDict_Contains into _PyDict_Contains_KnownHash.
* Correctly compare the hint against the keys in _PyDict_GetItemHint (GH-22960)Pablo Galindo2020-10-251-1/+1
|
* bpo-42093: Add opcode cache for LOAD_ATTR (GH-22803)Pablo Galindo2020-10-201-0/+65
|
* bpo-41493: Refactoring dictresize (GH-21751)Inada Naoki2020-08-071-26/+41
| | | Split newsize calculation into new function. dictresize() now accepts exact newsize.
* bpo-41431: Optimize dict_merge for copy (GH-21674)Inada Naoki2020-08-041-29/+67
|
* bpo-41333: Convert OrderedDict.pop() to Argument Clinic (GH-21534)Serhiy Storchaka2020-07-191-2/+3
|
* bpo-40521: Cleanup code of free lists (GH-21082)Victor Stinner2020-06-231-14/+16
| | | Add get_xxx_state() function to factorize duplicated code.
* bpo-40521: Make dict free lists per-interpreter (GH-20645)Victor Stinner2020-06-231-59/+66
| | | | | | | | | | | Each interpreter now has its own dict free list: * Move dict free lists into PyInterpreterState. * Move PyDict_MAXFREELIST define to pycore_interp.h * Add _Py_dict_state structure. * Add tstate parameter to _PyDict_ClearFreeList() and _PyDict_Fini(). * In debug mode, ensure that the dict free lists are not used after _PyDict_Fini() is called. * Remove "#ifdef EXPERIMENTAL_ISOLATED_SUBINTERPRETERS".
* bpo-40890: Fix compiler warning in dictobject.c (GH-20876)Pablo Galindo2020-06-151-3/+2
|
* bpo-40890: Add `mapping` property to dict views (GH-20749)Dennis Sweeney2020-06-121-3/+20
|
* bpo-40889: Optimize dict.items() ^ dict.items() (GH-20718)Dennis Sweeney2020-06-101-0/+90
|
* bpo-40839: PyDict_GetItem() requires the GIL (GH-20580)Victor Stinner2020-06-021-29/+26
| | | | Calling PyDict_GetItem() without GIL held had been allowed for historical reason. It is no longer allowed.
* bpo-40575: Avoid unnecessary overhead in _PyDict_GetItemIdWithError() (GH-20018)scoder2020-05-111-1/+3
| | | | | Avoid unnecessary overhead in _PyDict_GetItemIdWithError() by calling _PyDict_GetItem_KnownHash() instead of the more generic PyDict_GetItemWithError(), since we already know the hash of interned strings.
* bpo-40521: Disable free lists in subinterpreters (GH-19937)Victor Stinner2020-05-051-4/+33
| | | | | | | | | When Python is built with experimental isolated interpreters, disable tuple, dict and free free lists. Temporary workaround until these caches are made per-interpreter. Add frame_alloc() and frame_get_builtins() subfunctions to simplify _PyFrame_New_NoTrack().
* bpo-40428: Remove PyTuple_ClearFreeList() function (GH-19769)Victor Stinner2020-04-291-7/+4
| | | | | | | | | | | | | | | | | | | Remove the following function from the C API: * PyAsyncGen_ClearFreeLists() * PyContext_ClearFreeList() * PyDict_ClearFreeList() * PyFloat_ClearFreeList() * PyFrame_ClearFreeList() * PyList_ClearFreeList() * PySet_ClearFreeList() * PyTuple_ClearFreeList() Make these functions private, move them to the internal C API and change their return type to void. Call explicitly PyGC_Collect() to free all free lists. Note: PySet_ClearFreeList() did nothing.
* bpo-40268: Remove a few pycore_pystate.h includes (GH-19510)Victor Stinner2020-04-141-2/+3
|
* bpo-39481: Implementation for PEP 585 (#18239)Guido van Rossum2020-04-071-0/+1
| | | | | | | | | | | | This implements things like `list[int]`, which returns an object of type `types.GenericAlias`. This object mostly acts as a proxy for `list`, but has attributes `__origin__` and `__args__` that allow recovering the parts (with values `list` and `(int,)`. There is also an approximate notion of type variables; e.g. `list[T]` has a `__parameters__` attribute equal to `(T,)`. Type variables are objects of type `typing.TypeVar`.
* bpo-37207: Use PEP 590 vectorcall to speed up dict() (GH-19280)Dong-hee Na2020-04-021-0/+33
|
* bpo-39943: Properly const the pointers in dictkeys_get_index (GH-19170)Andy Lester2020-03-261-5/+5
|
* bpo-36144: Dictionary Union (PEP 584) (#12088)Brandt Bucher2020-02-241-18/+53
|
* bpo-39573: Clean up modules and headers to use Py_IS_TYPE() function (GH-18521)Dong-hee Na2020-02-171-6/+6
|
* bpo-39245: Switch to public API for Vectorcall (GH-18460)Petr Viktorin2020-02-111-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | The bulk of this patch was generated automatically with: for name in \ PyObject_Vectorcall \ Py_TPFLAGS_HAVE_VECTORCALL \ PyObject_VectorcallMethod \ PyVectorcall_Function \ PyObject_CallOneArg \ PyObject_CallMethodNoArgs \ PyObject_CallMethodOneArg \ ; do echo $name git grep -lwz _$name | xargs -0 sed -i "s/\b_$name\b/$name/g" done old=_PyObject_FastCallDict new=PyObject_VectorcallDict git grep -lwz $old | xargs -0 sed -i "s/\b$old\b/$new/g" and then cleaned up: - Revert changes to in docs & news - Revert changes to backcompat defines in headers - Nudge misaligned comments
* bpo-39573: Use Py_TYPE() macro in Objects directory (GH-18392)Victor Stinner2020-02-071-1/+1
| | | Replace direct access to PyObject.ob_type with Py_TYPE().
* bpo-39542: Simplify _Py_NewReference() (GH-18332)Victor Stinner2020-02-031-8/+18
| | | | | | | | | * Remove _Py_INC_REFTOTAL and _Py_DEC_REFTOTAL macros: modify directly _Py_RefTotal. * _Py_ForgetReference() is no longer defined if the Py_TRACE_REFS macro is not defined. * Remove _Py_NewReference() implementation from object.c: unify the two implementations in object.h inline function. * Fix Py_TRACE_REFS build: _Py_INC_TPALLOCS() macro has been removed.
* bpo-38588: Fix possible crashes in dict and list when calling ↵Dong-hee Na2019-12-311-0/+2
| | | | | | PyObject_RichCompareBool (GH-17734) Take strong references before calling PyObject_RichCompareBool to protect against the case where the object dies during the call.
* bpo-38613: Optimize set operations of dict keys. (GH-16961)Inada Naoki2019-11-081-21/+33
|
* bpo-38555: Fix an undefined behavior. (GH-16883)Serhiy Storchaka2019-10-231-8/+7
|
* bpo-38525: Fix a segmentation fault when using reverse iterators of empty ↵Dong-hee Na2019-10-191-2/+7
| | | | | dict (GH-16846) The reverse iterator for empty dictionaries was not handling correctly shared-key dictionaries.
* bpo-38202: Fix a crash in dict_view & non-itearble. (GH-16241)Zackery Spytz2019-10-131-0/+4
|
* Fix strict-aliasing rules errors on gcc 4.8.5. (GH-16714)Dong-hee Na2019-10-111-1/+1
|
* bpo-36389: _PyObject_CheckConsistency() available in release mode (GH-16612)Victor Stinner2019-10-071-16/+20
| | | | | | | | | | | | | | | | | | | | | bpo-36389, bpo-38376: The _PyObject_CheckConsistency() function is now also available in release mode. For example, it can be used to debug a crash in the visit_decref() function of the GC. Modify the following functions to also work in release mode: * _PyDict_CheckConsistency() * _PyObject_CheckConsistency() * _PyType_CheckConsistency() * _PyUnicode_CheckConsistency() Other changes: * _PyMem_IsPtrFreed(ptr) now also returns 1 if ptr is NULL (equals to 0). * _PyBytesWriter_CheckConsistency() now returns 1 and is only used with assert(). * Reorder _PyObject_Dump() to write safe fields first, and only attempt to render repr() at the end.
* Fix a compile warning in dictobject.c (GH-16610)Hai Shi2019-10-071-1/+0
|
* bpo-38210: Fix intersection operation with dict view and iterator. (GH-16602)Dong-hee Na2019-10-061-8/+0
|
* bpo-38219: Optimize dict creating and updating by a dict. (GH-16268)Serhiy Storchaka2019-09-251-8/+13
|
* bpo-37206: Unrepresentable default values no longer represented as None. ↵Serhiy Storchaka2019-09-141-2/+2
| | | | | | | (GH-13933) In ArgumentClinic, value "NULL" should now be used only for unrepresentable default values (like in the optional third parameter of getattr). "None" should be used if None is accepted as argument and passing None has the same effect as not passing the argument at all.
* Fix typo in dict object comment (#15814)dalgarno2019-09-101-1/+1
|
* Make PyXXX_Fini() functions private (GH-15531)Victor Stinner2019-08-271-1/+1
| | | | | For example, rename PyTuple_Fini() to _PyTuple_Fini(). These functions are only declared in the internal C API.
* bpo-27575: port set intersection logic into dictview intersection (GH-7696)Forest Gregg2019-08-261-4/+77
|
* bpo-37648: Fixed minor inconsistency in some __contains__. (GH-14904)Serhiy Storchaka2019-08-041-1/+1
| | | | | The collection's item is now always at the left and the needle is on the right of ==.
* bpo-37547: add _PyObject_CallMethodOneArg (GH-14685)Jeroen Demeyer2019-07-111-4/+4
|
* bpo-37483: add _PyObject_CallOneArg() function (#14558)Jeroen Demeyer2019-07-041-2/+1
|