range() is not the best way to check range?

bearophileHUGS at lycos.com bearophileHUGS at lycos.com
Tue Jul 18 16:11:53 EDT 2006


Dan Bishop:
> 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?

I think this is a nice idea.

Bye,
bearophile




More information about the Python-list mailing list