lazyseq: a lazily evaluated sequence type for Python
lazyseq is a simple library implementing a single class, LazySeq, which provides a lazily evaluated sequence that can be used like an immutable list. You can think of it as a Pythonic version of Clojure’s Seq. The main use of LazySeq is for wrapping generators or generator expressions to make them persistent, but still lazy.
LazySeq implements Python’s sequence interface, and thus has the methods __getitem__, __len__, __contains__, __iter__, __reversed__, index, and count.
Getting an item from a LazySeq is equivalent to getting an items from the provided iterable as a list. However, only the necessary elements of the iterable are evaluated (all those up to the maximum requested element), and all evaluated elements are cached on the LazySeq so it can be iterated over again. Note that some operations like len(seq) will by necessity iterate over (and thus cache) the entire iterable.
To use LazySeq, just call LazySeq on any Python iterable:
>>> from lazyseq import LazySeq
>>> seq = LazySeq(x ** 2 for x in range(5))
>>> seq
LazySeq([...])
>>> seq[:3]
[0, 1, 4]
>>> seq
LazySeq([0, 1, 4, ...])
>>> list(seq)
[0, 1, 4, 9, 16]
>>> seq
LazySeq([0, 1, 4, 9, 16])
Metadata
Release files for lazyseq 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| lazyseq-0.1.1.tar.gz | 2.5 kB | Without provenance | Details for lazyseq-0.1.1.tar.gz |
Release files / lazyseq-0.1.1.tar.gz
| Download URL | lazyseq-0.1.1.tar.gz |
|---|---|
| Size | 2.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
6b97c3ba0409bce295963aceedb75b4f98021d65227c37f181b841e405b6903f
|
|
BLAKE2b-256 checksum How to use checksums |
286806f8d1dfb10c8ebde82cda785b337efe4b3b103d4e1855de98a1a55a2d92
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for lazyseq 0.1.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.