[issue44555] Dictionary operations are LINEAR for any dictionary (for a particular code).

Dennis Sweeney report at bugs.python.org
Sat Jul 3 13:03:18 EDT 2021


Dennis Sweeney <sweeney.dennis650 at gmail.com> added the comment:

OrderedDict already uses a linked list alongside a dictionary and meets all of your timing expectations, but has a higher memory usage, as linked lists generally do.

Since so many Python objects use dictionaries under the hood, it would probably not be worth it to completely change the dict structure and the memory usage of Python as a whole to only benefit this uncommon case. See Objects/dictnotes.txt for the highest priority use cases of dicts.

Per the OrderedDict docs, ordering is only secondary for dicts, but it's the focus for OrderedDicts. Just like you wouldn't send a list to do the job of a deque or vice versa, I don't think you should send an dict to do the job of an OrderedDict or vice versa.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue44555>
_______________________________________


More information about the Python-bugs-list mailing list