[pypy-dev] __builtin__ module
Armin Rigo
arigo at tunes.org
Sat Jan 25 12:32:16 CET 2003
Hello Nathan,
On Fri, Jan 24, 2003 at 10:23:46AM -0600, Nathan Heagy wrote:
> > "i not in range(256)"
>
> Why not "if 0 < i < 256:" ?
Ultimately because "i in range()" is a single test. This is what we want to
say: "i is in the acceptable range". A translator working on the "0 <= i <
256" version would have to use patterns to figure out that we are actually
asking whether "i" is within a range, and not simply making two tests "0 <= i"
and "i < 256", in case it allows to generate more natural code. Conversely,
it is trivial to implement "in range()" as a double comparison if needed.
Armin
More information about the Pypy-dev
mailing list