Paul Boddie wrote:

> Yes, he wants range to return an iterator, just like xrange more or
> less does now. Given that xrange objects support __getitem__, unlike a
> lot of other iterators (and, of course, generators), adding
> __contains__ wouldn't be much of a hardship. Certainly, compared to
> other notational conveniences bounced around on the various development
> lists, this one would probably provide an order of magnitude
> improvement on the usual bang per buck development ratio.

xrange already has __contains__.  The problem is, it's implemented by a
highly-inefficient sequential search.  Why not modify it to merely
check the bounds and (value - start) % step == 0?

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to