[Python-Dev] Allowing slicing of iterators

Nick Coghlan ncoghlan at iinet.net.au
Mon Jan 24 12:30:01 CET 2005

I just wrote a new C API function (PyItem_GetItem) that supports slicing for 
arbitrary iterators. A patch for current CVS is at http://www.python.org/sf/1108272

For simple indices it does the iteration manually, and for extended slices it 
returns an itertools.islice object.

As a trivial example, here's how to skip the head of a zero-numbered list:

   for i, item in enumerate("ABCDEF")[1:]:
     print i, item

Is this idea a non-starter, or should I spend my holiday on Wednesday finishing 
it off and writing the documentation and tests for it?


Nick Coghlan   |   ncoghlan at email.com   |   Brisbane, Australia

More information about the Python-Dev mailing list