• Raymond Hettinger's avatar
    Tidied up the implementations of reversed (including the custom ones · ef9bf403
    Raymond Hettinger yazdı
    for xrange and list objects).
    
    * list.__reversed__ now checks the length of the sequence object before
      calling PyList_GET_ITEM() because the mutable could have changed length.
    
    * all three implementations are now tranparent with respect to length and
      maintain the invariant len(it) == len(list(it)) even when the underlying
      sequence mutates.
    
    * __builtin__.reversed() now frees the underlying sequence as soon
      as the iterator is exhausted.
    
    * the code paths were rearranged so that the most common paths
      do not require a jump.
    ef9bf403
test_enumerate.py 4.66 KB