While Python 3 has stricter checks on iterators on dictionaries, they can still produce poorly defined, unexpected results without an error being raised: the only check is that any time an element is fetched, the length of the dictionary equals the length it had when the iterator was created. If entries are only changed (not added or deleted), iteration is pretty well-defined: you'll see every key once.
However, if a lot of keys are deleted and then recreated, a reshaping of the dictionary may still be triggered and then results on the returned keys are quite hard to predict. Example: W = dict(enumerate(range(2000))) I = iter(W) K = [] # fetch some elements from the iterator for i in range(20): K.append(next(I)) # delete half of the entries for i in range(0, 2000, 2): del W[i] # and put other ones back for i in range(0, 2000, 2): W[i]=i #and fetch the rest of the iterator for i in range(20, 2000): K.append(next(I)) 21 in K # this is false 21 in W # this is true # so, we've never seen key 21. Obviously, there are other keys we've seen multiple times now. # and we check the iterator is done: next(I) # raises StopIteration -- You received this message because you are subscribed to the Google Groups "sage-devel" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-devel+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/sage-devel/bf850faa-7359-4d6a-98e9-82ce12c120e4n%40googlegroups.com.