2 Oct
2011
2 Oct
'11
10:09 p.m.
On 10/2/2011 4:25 PM, Guido van Rossum wrote:
On Sun, Oct 2, 2011 at 12:57 PM, Antoine Pitrou
wrote: Hello? The issue is not that walking over an iterator changes the state of the iterator, it is that "x in A" iterates over A at all.
Hello? That is the original definition of "in".
I had the same reaction as Guido. Iteration is the *only* generic way to tell if an item is in a sequence or other collection . The direct hash access of sets and dicts is exceptional. The direct calculation for range is a different exception. For the other builtin sequences, and for typical iterators, which lack the information for an O(1) shortcut, 'in' (and .__contains__ if present) has to be iteration based. -- Terry Jan Reedy