[issue38278] Need a more efficient way to perform dict.get(key, default)
STINNER Victor
report at bugs.python.org
Wed Sep 25 10:52:09 EDT 2019
STINNER Victor <vstinner at python.org> added the comment:
> Lots of solutions are possible - maybe some kind of peephole optimization to make dict.get() itself perform similarly to the [] operator, or if that's challenging perhaps providing a class or option that behaves like defaultdict but without the auto-adding behaviour and with comparable [] performance to the "dict" type - for example dict.raiseExceptionOnMissing=False, or perhaps even some kind of new syntax (e.g. dict['key', default=None]). Which option would be easiest/nicest?
This issue doesn't propose any concrete solution, but discuss ideas. I suggest you to open a thread on the python-ideas mailing list instead. I suggest to close this issue.
I bet that defaultdict is *not* faster once you will manage to write a fair micro-benchmark.
----------
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue38278>
_______________________________________
More information about the Python-bugs-list
mailing list