l = range(int(1E9))

Terry Reedy tjreedy at udel.edu
Thu Apr 30 19:02:47 CEST 2015

On 4/30/2015 12:06 PM, Cecil Westerhof wrote:
> If I execute:
>      l = range(int(1E9)

you get a SyntaxError

> The python process gobbles up all the memory and is killed. The
> problem is that after this my swap is completely used, because other
> processes have swapped to it. This make those programs more slowly. Is
> there a way to circumvent Python claiming all the memory?

For this specific case, use xrange or 3.x range

> By the way: this is CPython 2.7.8.

Terry Jan Reedy

More information about the Python-list mailing list