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 and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page