[Tutor] Why does counting to 20 million stress my computer?

Alan Gauld alan.gauld at blueyonder.co.uk
Wed Jul 21 23:38:32 CEST 2004


> Yes, I went with xrange(). But you've got me curious. I looked up
> generators in _Learning Python_, 2nd ed. Not sure I understand them,
but
> would you expect using a generator to be a faster way to count than
using
> xrange()? Could you give me an example that would fit my spin3.py
below?

Not necessarily faster but it would lock up the PC as you originally
saw.
I think I read that generators are replacing xrange (or maybe xrange
is
just reimplemented using generators?)

Alan G



More information about the Tutor mailing list