Skip to main content

Lazily Resolving Sequence

Project description

Latest version https://travis-ci.org/ryanhiebert/genseq.svg?branch=master

Genseq is sequence data structure that lazily consumes any iterable, including a generator, so that you can enjoy the benefits of both delayed evaluation, and the slicing and random access of lists.

The Genseq class implements the collections Sequence ABC, so the standard methods of using an immutable sequence are all available.

Usage

Install using Pip:

pip install genseq

Then wrap your generator with genseq:

>>> from genseq import genseq
>>> @genseq
... def myiter(stop):
...     for i in range(stop):
...         yield i
...
>>> myiter(5)[2]
2
>>>

Or use the Genseq class on any iterable:

>>> from genseq import Genseq
>>> Genseq(range(5))[3]
3
>>>

Happy indexing!

Project details


Release history Release notifications | RSS feed

This version

1.0

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page