Serhiy Storchaka added the comment: Yes, the difference is pretty small. The largest difference I got is 7% in following microbenchmark:
$ ./python -m perf timeit -s 'x = list(range(1000))' -- 'dict.fromkeys(x)' Unpatched: Median +- std dev: 80.6 us +- 0.5 us dictresize3.patch: Median +- std dev: 80.9 us +- 2.8 us dictresize4.patch: Median +- std dev: 75.4 us +- 2.1 us I suppose this is due to using memcpy. In other microbenchmarks the difference usually is 1-2%. Xiang, your microbenchmark don't work for this patch because dict(d) make only one resizing. > Cons of Serhiy's patch is it's two pass. If entries are larger than L2 cache, fetch from L3 cache may be larger. Agree. But on other hand, dictresize3.patch needs to fit in L2 cache all indices table and prefetch two entries arrays: old and new. dictresize4.patch in every loop works with smaller memory: two entries arrays in the first loop and an indices table and new entries arrays in the second loop. ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue28199> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com