[Python-3000] optimizing [x]range (original) (raw)
Guido van Rossum guido at python.org
Sun Jul 29 19:33:34 CEST 2007
- Previous message: [Python-3000] optimizing [x]range
- Next message: [Python-3000] optimizing [x]range
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On 7/28/07, Johan Dahlin <jdahlin at async.com.br> wrote:
Guido van Rossum wrote: > Do we really need another way to spell a <= x < b?
FWIW, I'd say yes; I sometimes find it a bit difficult to remember how the operator should be placed, there are several possible ways of making a mistake, eg; a > x < b_ _a < x > b a < x < b_ _a > x > b
Were you drunk at the time? :-)
Now, the range syntax seems a bit strange at first, but I find it easier to parse:
if x in range(a, b) There's no way to incorrectly parse that, it's immediately known that the programmer tries to see whether x is in a specific range. It seems to be used quite widely already; http://google.com/codesearch?hl=en&q=+%5E.if%5Cs%2B.%5Cs%2Bin%5Cs%2Brange%5C(.*%24&start=10&sa=N
Sorry, 50 hits is not "quite widely".
Did you find any examples using a step > 1?
-- --Guido van Rossum (home page: http://www.python.org/~guido/)
- Previous message: [Python-3000] optimizing [x]range
- Next message: [Python-3000] optimizing [x]range
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]