Serhiy Storchaka <storchaka+cpyt...@gmail.com> added the comment:

+1 to all said by Raymond. But this is rather the matter of a special article 
or blog post than a note in the documentation.

Other example of caching is regular expressions.

Mistakes:

python3 -m timeit -s "it = iter(range(1000000000))" "next(it)"

python3 -m timeit -s "a = []" "a.append(1)"

I remember one non-obvious trap in which I got caught. The performance of the 
iteration of a dict was influenced by the fact that in new dicts the order of 
iteration coincided with the order of creating keys, which were allocated 
sequentially in memory. Thus refcounts were touched in adjacent objects. This 
usually is not happen in real programs.

----------
nosy: +serhiy.storchaka

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue32039>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to