[Python-Dev] xrange identity crisis
Martin v. Loewis
05 Jun 2002 09:30:05 +0200
Guido van Rossum <firstname.lastname@example.org> writes:
> Is it really so bad if this allocates *two* objects instead of one?
When accepting the patch, I assumed that the observed speed difference
between xrange and range originated from the fact that xrange
iteration allocates iterator objects. I'm not so sure anymore that
this is the real cause, more likely, it is again the exception
handling when exhausting the range.
> I think that's the only to get my example to work correctly. And it
> *has* to work correctly.
> If two objects are created anyway, I agree with Oren that it's better
> to have a separate range-iterator object type.
I agree. I wouldn't mind if somebody would review Raymond's to
introduce such a thing.