> > Consulting two dictionaries instead of one is a very very very > > minor penalty. > > It's more than twice as expensive: not only do you have to do two look > ups rather than one, but you have to also look up the second dict as > well. And there's the overhead of the ChainMap itself. > > > $ ./python -m timeit -s "d = {}" "d.get('aardvark')" > 500000 loops, best of 5: 702 nsec per loop > > $ ./python -m timeit -s "from collections import ChainMap" -s "d = > ChainMap([{}, {}])" "d.get('aardvark')" > 20000 loops, best of 5: 12.3 usec per loop > > That's 17 times slower on my PC. >
Well that's the death rattle on that particular crackpot idea. >
_______________________________________________ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@python.org https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at https://mail.python.org/archives/list/python-ideas@python.org/message/BIAZZQGCAK2APVVMVOW46Q7TCSMKWTO2/ Code of Conduct: http://python.org/psf/codeofconduct/