Jon Ribbens <jon+use...@unequivocal.co.uk> writes: > On 2015-04-30, Cecil Westerhof <ce...@decebal.nl> wrote: > > If I execute: > > l = range(int(1E9) > > > > The python process gobbles up all the memory and is killed. […] Is > > there a way to circumvent Python claiming all the memory?
You seem to be asking for a way to stop a program doing exactly what it's written to do. I don't know what kind of answer you expect. > It's your operating system's job to handle processes. Indeed. In this case, the program is written to gobble up memory, and the operating system kills it. To “circumvent” that behaviour surely reveals the problem: that the operating system isn't handling processes very well. > > By the way: this is CPython 2.7.8. > > If you use xrange() instead of range() then you will get an iterator > which will return each of the numbers in turn without any need to > create an enormous list of all of them. If you use Python 3 instead of the obsolescent Python 2, the ‘range’ callable has this sensible behaviour by default. -- \ “Corporation, n. An ingenious device for obtaining individual | `\ profit without individual responsibility.” —Ambrose Bierce, | _o__) _The Devil's Dictionary_, 1906 | Ben Finney -- https://mail.python.org/mailman/listinfo/python-list