HNHacker News
TopNewBestAskShowJobs

ztraxc

2 karma · joined June 18, 2023

submissionscomments
ztraxc··on Python Dict – An Explorable Explanation
For inserting and looking up 10,000,000 integer values with string keys I get 6.4s for both Python and SBCL and 5.2 seconds for C++ (std::string, unordered_map).

Python's dict implementation (in C) is good and the interpreter loop overhead is dwarfed by the dict overhead.

SBCL's implementation is in Lisp and achieves the same speed.

(For the general case of Python speed this benchmark is of course useless, since raw dicts written in C cannot be optimized much. Nevertheless it is sometimes quoted as "evidence" that "Python is almost as fast as C++" ...)