[issue38278] Need a more efficient way to perform dict.get(key, default)

STINNER Victor report at bugs.python.org
Wed Sep 25 10:46:22 EDT 2019


STINNER Victor <vstinner at python.org> added the comment:

dict.get() is a method call wheras "key in dict" and "dict[key]" are operators. Method calls are still slower than operators, even after past optimizations. For example, when dict.get was converted to METH_FASTCALL, it was around 20 ns faster:
https://vstinner.github.io/fastcall-microbenchmarks.html

See also closed bpo-17170 "string method lookup is too slow".

----------
nosy: +serhiy.storchaka, vstinner

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


More information about the Python-bugs-list mailing list