Python hits the spot

Tim Peters at
Sun Jun 23 23:38:36 CEST 2002

[Pär Kurlberg, sees this freeze some Linux box]
> for i in range(50*1000*1000):
>    pass

[Matt Gerrans]
> You call that a bug?   Did you consider trying xrange()?

[Paul Rubin]
> Maybe not a bug, but a pretty serious misfeature IMO.

If it is, it's a serious misfeature of Linux's overcommitment policies.
Python does a malloc() sufficient for 50*1000*1000 list elements at the
start (about 200Mb), malloc doesn't return NULL, and Python believes it can
use the memory.  What would you like it to do instead?  The platform libc
and platform OS don't give any clue that they're making promises they can't
keep.  If at any point in the process this-- or any subsequent --malloc()
returned NULL, Python would raise a well-behaved MemoryError and clean up
the partial junk.

But when the OS+libc refuse to give any hint of trouble, and themselves go
nuts later, I don't accept that as being Python's problem.  As noted, more
recent versions of Linux kill the process (well, kill *some* process(es),
probably including at least this one) instead of going completely insane.
That sounds like a misfeature to me too, but it's outside of Python's

python-isn't-an-operating-system-ly y'rs  - tim

More information about the Python-list mailing list