Message397019
> I still disagree with this design since it's not
> how a person using a hash map expects it to behave.
All mapping data structures have tradeoffs. For the core dict type, we chose a structure that benefits most Python users most of the time. If a user expects that the core dict type magically handles all cases optimally, that is a bug in their expectation, not a bug in Python.
For the atypical pattern shown in slow_dictionary(), we recommend choosing a different data structure such as an OrderedDict or simply storing the keys in a deque. This isn't a blow-off answer -- the stated goal of the collections module is to offer "specialized container datatypes providing alternatives to Python’s general purpose built-in containers, dict, list, set, and tuple." Those alternatives have different performance characteristics that may better serve particular access patterns.
Thanks for the suggestion, but this is not a bug. It is an intentional design decision. Changing the dict implementation to a linked list would make your case perform better but would make most users worse off. |
|
Date |
User |
Action |
Args |
2021-07-05 20:38:37 | rhettinger | set | recipients:
+ rhettinger, methane, serhiy.storchaka, Dennis Sweeney, danielfleischman |
2021-07-05 20:38:37 | rhettinger | set | messageid: <1625517517.89.0.211165025671.issue44555@roundup.psfhosted.org> |
2021-07-05 20:38:37 | rhettinger | link | issue44555 messages |
2021-07-05 20:38:37 | rhettinger | create | |
|