range() vs xrange() Python2|3 issues for performance

Chris Angelico rosuav at gmail.com
Tue Aug 2 12:06:21 EDT 2011


On Tue, Aug 2, 2011 at 3:45 PM, Steven D'Aprano
<steve+comp.lang.python at pearwood.info> wrote:
> (But don't make the mistake of doing what I did, which was to attempt to
> produce range(290000000) in Python 2. After multiple *hours* of swapping, I
> was finally able to kill the Python process and get control of my PC again.
> Sigh.)
>

That is sad. (And, I am only slightly ashamed to admit it, quite
funny.) But on the other hand, quite impressive that it didn't bomb
anywhere!

Whenever I'm about to do something really dangerous, I like to first
open an SSH session from another computer - bash running inside there
can usually kill any process fairly efficiently, without need for UI
interaction. Failing that, good ol' Ctrl-Alt-F1 to get to a console is
usually the next best, but sometimes logging in requires a lot of
resources.

This is actually one place where I'm really glad Python doesn't do
much with multiple threads (for instance, it won't gc on another
thread). A dual core CPU keeps everything happy!

ChrisA



More information about the Python-list mailing list