[Python-ideas] lazy list
Terry Reedy
tjreedy at udel.edu
Thu May 14 18:51:40 CEST 2015
On 5/14/2015 11:01 AM, Chris Angelico wrote:
> On Fri, May 15, 2015 at 12:52 AM, Alexander Atkins
> <alexander at tutorfair.com> wrote:
>> 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?
This is a memoizer using a list rather than a dict. This is appropriate
for f(count) = g(count-1).
> It may well already exist on PyPI. There are a few things with "lazy"
> in their names; you'd have to poke around and see if one of them is of
> use to you.
I would also try 'memo' and 'memoize'.
> Another thing you might want to search for is "indexable map()", which
> is a related concept (imagine calling map() with a function and a
> list; the result is theoretically subscriptable, but not with Py3's
> basic map() implementation) that I'm fairly sure I've seen around at
> times.
>
> https://pypi.python.org/pypi
>
> Have fun searching. There's a huge lot out there, most of which isn't
> what you want... but you never know what you'll find!
The problem with putting any one thing in stdlib is that there are so
many little variations.
--
Terry Jan Reedy
More information about the Python-ideas
mailing list