[Python-3000] optimizing [x]range
skip at pobox.com
skip at pobox.com
Tue Jul 31 12:22:56 CEST 2007
>> if j in r:
>> ...
>>
>> Given the context, I think this is a very Obvious Way To Do It, and
>> it's surprising that it isn't as efficient as it looks like it should
>> be.
Guido> Fair enough. So maybe *you* can contribute a patch?
Given the nature of this discussion and who you're asking to provide a
patch, I'd rather see a patch for this:
Python 3.0x (py3k-struni:56553M, Jul 26 2007, 13:34:26)
[GCC 4.0.1 (Apple Computer, Inc. build 5367)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> for 0 <= i < 10 by 3:
... print(i)
...
0
3
6
9
:-) (Yes, I know the language is frozen at this point.)
Also, bringing it back more on-topic, what should the value of this
expression be?
4 in range(0, 10, 3)
That is, are we treating range() as a set or an interval? Maybe I missed
earlier messages in this thread where this was discussed, but part of the
discussion focused on this construct
0 <= 4 < 10
where there was no option to provide a step size. Also, this particular
notation screams out interval, not set, to me.
Skip
More information about the Python-3000
mailing list