Message353208
>python -m timeit -s "import collections; d=collections.defaultdict(lambda: None); d['abc']=123; " "x=d['XXX']"
5000000 loops, best of 5: 34.3 nsec per loop
This benchmark is not a fair comparison: the 'XXX' key is created at the first access. In short, this benchmark measure the performance of a dict lookup:
>python -m timeit -s "d={'abc':123}" "x=d['abc']"
5000000 loops, best of 5: 33 nsec per loop |
|
Date |
User |
Action |
Args |
2019-09-25 14:49:32 | vstinner | set | recipients:
+ vstinner, serhiy.storchaka, benspiller |
2019-09-25 14:49:32 | vstinner | set | messageid: <1569422972.35.0.489199177995.issue38278@roundup.psfhosted.org> |
2019-09-25 14:49:32 | vstinner | link | issue38278 messages |
2019-09-25 14:49:32 | vstinner | create | |
|