[Python-ideas] lazy list

Alexander Atkins alexander at tutorfair.com
Thu May 14 16:52:55 CEST 2015


Hi, I'm new to this mailing list.

I needed a lazy list implementation for something, so I created one.  I was
a little bit surprised to find that there wasn't one in the *itertools*
module and it seemed like quite a basic thing to me, as someone who has
used Haskell before, so I thought probably I should share it.  I'm
wondering whether something like this should be part of the standard
library?

A fuller explanation is in the README, which is here:
https://github.com/jadatkins/python-lazylist
The gist of it is that it allows you to index into a generator.  Previously
evaluated elements are remembered, so foo[5] returns the same thing each
time, and you can later call foo[4] and get the previous element.  There
are many uses for such a thing, but if you're not expecting it in the
language, you might not necessarily think of them.

Warning: it may contain bugs, especially the stuff to do with slicing,
which is not really what it's for.

--

*J Alexander D Atkins*
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20150514/30bfd04d/attachment-0001.html>


More information about the Python-ideas mailing list