Skip to main content

Proxy list to a list-returning function

Project description

PyPI Build Status

This small package provides a proxy list to a list-returning function:

>>> from lazylist import LazyList
>>> l = LazyList(lambda: x)
>>> x = [1, 2, 3]
>>> list(l)
[1, 2, 3]

More precisely, view function doesn’t have to return an exact list, but an any squence object e.g. str, tuple:

>>> x = "hello"
>>> list(l)
['h', 'e', 'l', 'l', 'o']

It satisfies collections.abc.Sequence protocol:

>>> from collections import Sequence
>>> isinstance(l, Sequence)
True
>>> l[-1]
'o'
>>> len(l)
5

However, it doesn’t satisfy collections.abc.MutableSequence protocol. In other words, it’s immutable:

>>> from collections import MutableSequence
>>> isinstance(l, MutableSequence)
False
>>> l[0] = 'H'
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: 'LazyList' object does not support item assignment

Distributed under LGPLv3 or higher.

Todos

  • LazySet
  • LazyMap

Release history Release notifications

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Filename, size & hash SHA256 hash help File type Python version Upload date
lazylist-0.9.0-py2.py3-none-any.whl (3.9 kB) Copy SHA256 hash SHA256 Wheel 3.5
lazylist-0.9.0.tar.gz (2.3 kB) Copy SHA256 hash SHA256 Source None

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page