PC locks up with list operations
steve+comp.lang.python at pearwood.info
Wed Aug 31 14:33:15 CEST 2011
Twice in a couple of weeks, I have locked up my PC by running a Python 2.5
script that tries to create a list that is insanely too big.
In the first case, I (stupidly) did something like:
mylist = *12345678901234
After leaving the machine for THREE DAYS (!!!) I eventually was able to get
to a console and kill the Python process. Amazingly, it never raised
MemoryError in that time.
The second time was a little less stupid, but not much:
mylist = 
for x in itertools.combinations_with_replacement(some_big_list, 20):
After three hours, the desktop is still locked up. I'm waiting to see what
happens in the morning before rebooting.
Apart from "Then don't do that!", is there anything I can do to prevent this
sort of thing in the future? Like instruct Python not to request more
memory than my PC has?
I am using Linux desktops; both incidents were with Python 2.5. Do newer
versions of Python respond to this sort of situation more gracefully?
More information about the Python-list