This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author jdemeyer
Recipients jdemeyer, methane, skrah, vstinner
Date 2019-07-03.10:53:54
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
> Is there any benchmark showing if it's faster

Here is one example:

class D(dict):
    def __missing__(self, key):
        return None
d = D()

and now benchmark d[0]

**before**: Mean +- std dev: 173 ns +- 1 ns
**after**: Mean +- std dev: 162 ns +- 1 ns

To be precise, I ran: ./python -m perf timeit --duplicate 200 -s 'class D(dict):' -s ' def __missing__(self, key):' -s '  return None' -s 'd = D()' 'd[0]'
Date User Action Args
2019-07-03 10:53:54jdemeyersetrecipients: + jdemeyer, vstinner, methane, skrah
2019-07-03 10:53:54jdemeyersetmessageid: <>
2019-07-03 10:53:54jdemeyerlinkissue37483 messages
2019-07-03 10:53:54jdemeyercreate