micropython/micropython — pull request #59 by pfalcon (2014-01-04 00:48:51+00:00)
Title: Implement basic slice object and string slicing

This implements efficient subset of Python slicing. Only 2-argument (start, stop) is supported, and arguments must be integers (CPython allows slice arguments to be of any type). This should cover realistic needs one would have with MicroPython. The only interesting for optimization case of 3rd argument is -1, as idiom for reversing slice. But we would have generic reversed() function and .reverse() methods, so, again, that should cover MicroPython needs and I don't think step=-1 case should be optimized (at least not now).

If ever will want full CPython semantics, suggested route is to implement separate object type, and use that if argument pattern for optimal implementation above doesn't match. This generic slice type can use generic sequence iteration methods, be fully correct re:CPython, and thus awfully slow.