Skip to main content
Join the official 2019 Python Developers SurveyStart the survey!

A lazy-loading, fancy-sliceable iterable.

Project description

a lazy-loading, fancy-slicable iterable

Think of it like a generator that is “reusable” and has a length.

Please see the documentation for examples and an API reference.

build status Documentation Status

Installation

On any platform, use pip or conda.

pip install slicerator

or

conda install -c soft-matter slicerator

Example

from slicerator import Slicerator

@Slicerator.from_class
class MyLazyLoader:
    def __getitem__(self, i):
        # this method will be wrapped by Slicerator, so that it accepts slices,
        # lists of integers, or boolean masks. Code below will only be executed
        # when an integer is used.

        # load thing number i
        return thing

    def __len__(self):
        # do stuff
        return number_of_things


# Demo:
>>> a = MyLazyLoader()
>>> s1 = a[::2]  # no data is loaded yet
>>> s2 = s1[1:]  # no data is loaded yet
>>> some_data = s2[0]

Project details


Download files

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

Files for slicerator, version 1.0.0
Filename, size File type Python version Upload date Hashes
Filename, size slicerator-1.0.0-py3-none-any.whl (9.3 kB) File type Wheel Python version py3 Upload date Hashes View hashes
Filename, size slicerator-1.0.0.tar.gz (26.3 kB) File type Source Python version None Upload date Hashes View hashes

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