26 Dec
2019
26 Dec
'19
8:08 a.m.
26.12.19 00:56, Tim Peters пише:
- I don't have a theory for why dict build time is _so_ much higher than dict lookup time for the nasty keys.
1/2 of items were copied to a new hashtable when the dict grew up. 1/4 of items were copied twice. 1/8 of items were copied three times, etc. In average every item is copied 1 time, so the build time is twice the lookup time when the cost of lookup is dominated. But the lookup benchmarking includes the overhead of iterating Python loop, which is more significant for "good" keys, thus the lookup time is larger than the build time.