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

tuple(range(size)) should consume approximately 90 GiB of memory and run for 
hours. I think this happens because it creates enormous number of integer 
objects, and this can lead to requesting additional memory for memory pools.

If details of memory management for small objects is not the purpose of this 
test, I think we can replace it with tuple(iter([42]*size)). It executes the 
same code in tuple creation: allocates a tuple of known size (both range and 
list iterators have __length_hint__) and fills it with values produced by the 
iterator. This allows significantly reduce memory requirements (to 16 GiB) and 
execution time (to 20 seconds on my computer).

The proposed PR implements this rewriting. It also fixes memory requirements 
for other tests, optimizes repr tests for tuples and lists (repr(False) is 
faster and longer than repr(0)), and expresses memory requirements in terms of 
character and pointer sizes.

----------
versions: +Python 3.7, Python 3.8 -Python 3.3

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

Reply via email to