Author serhiy.storchaka
Recipients llllllllll, nadeem.vawda, pitrou, serhiy.storchaka, steve.dower, twouters
Date 2018-12-11.22:26:51
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1544567211.78.0.788709270274.issue5438@psf.upfronthosting.co.za>
In-reply-to
Content
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.
History
Date User Action Args
2018-12-11 22:26:51serhiy.storchakasetrecipients: + serhiy.storchaka, twouters, pitrou, nadeem.vawda, steve.dower, llllllllll
2018-12-11 22:26:51serhiy.storchakasetmessageid: <1544567211.78.0.788709270274.issue5438@psf.upfronthosting.co.za>
2018-12-11 22:26:51serhiy.storchakalinkissue5438 messages
2018-12-11 22:26:51serhiy.storchakacreate