logoalt Hacker News

erutoday at 1:49 AM2 repliesview on HN

If you are willing to sacrifice performance, you can implement dicts via linear lookup in much less code than a proper hash table.


Replies

Someonetoday at 8:06 AM

Because Python dicts guarantee iteration order is the same as insertion order (https://docs.python.org/3.7/library/stdtypes.html#typesmappi...) Python dicts aren’t just proper hash tables.

Because of that it wouldn’t surprise me much if that sped up some standard benchmarks, for example ones parsing lots of small json objects into dictionaries.

FridgeSealtoday at 2:40 AM

It’s Python, you’ve already sacrificed performance, what a little bit more?

show 1 reply