<[EMAIL PROTECTED]> wrote: >mosscliffe: >> if key in xrange (60,69) or key == 3: >I keep seeing again and again code like this, mostly from people not >much expert of Python, but the PEP 260 shows the fast in was removed, >so it's O(n).
If you're going to point that out, you should at least also mention the "correct" formulation: if 60 <= key < 69 or key == 3: And if anyone cares about performance: $ python -mtimeit -s 'x = 67' 'x in range(60, 69)' 1000000 loops, best of 3: 0.906 usec per loop $ python -mtimeit -s 'x = 67' 'x in xrange(60, 69)' 1000000 loops, best of 3: 0.744 usec per loop $ python -mtimeit -s 'x = 61' 'x in range(60, 69)' 1000000 loops, best of 3: 0.707 usec per loop $ python -mtimeit -s 'x = 61' 'x in xrange(60, 69)' 1000000 loops, best of 3: 0.471 usec per loop $ python -mtimeit -s 'x = 67' '60 <= x < 69' 10000000 loops, best of 3: 0.155 usec per loop -- \S -- [EMAIL PROTECTED] -- http://www.chaos.org.uk/~sion/ "Frankly I have no feelings towards penguins one way or the other" -- Arthur C. Clarke her nu becomeþ se bera eadward ofdun hlæddre heafdes bæce bump bump bump
-- http://mail.python.org/mailman/listinfo/python-list