I am out of trial and error again Lists
rosuav at gmail.com
Fri Oct 24 05:32:18 CEST 2014
On Fri, Oct 24, 2014 at 2:14 PM, Terry Reedy <tjreedy at udel.edu> wrote:
> Example that works 'instantly' in 3.x, but would be slightly insane in 2.x,
> even if you have enough memory for it to work on a 64 bit build.
>>>> r =range(0, 1000000000000000, 999937)
>>>> 3428761974385 in r
>>>> 3428761974386 in r
That's over a billion entries. The array of pointers alone would be
roughly 4GB on a 32-bit build, so there's no way that'll ever fit...
on a 64-bit build, that'll take up 8GBish for the list, plus probably
24 bytes minimum per integer, so even if there's absolutely no heap
overhead, you're still looking at 32GB to store that list. Yeeeouch. I
think we can drop the "slightly" from your description! For
comparison, a 64-bit Python 3 says:
>>> sys.getsizeof(range(0, 1000000000000000, 999937))
Thanks, much nicer.
More information about the Python-list