A lazy-loading, fancy-sliceable iterable.
Project description
Slicerator
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.
Installation
On any platform, use pip or conda.
pip install slicerator
or
conda install -c conda-forge 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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
slicerator-1.1.0.tar.gz
(38.3 kB
view hashes)
Built Distribution
slicerator-1.1.0-py3-none-any.whl
(10.3 kB
view hashes)
Close
Hashes for slicerator-1.1.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 167668d48c6d3a5ba0bd3d54b2688e81ee267dc20aef299e547d711e6f3c441a |
|
MD5 | 8ac2736c328a5a9757cde7b5cee193f3 |
|
BLAKE2b-256 | e8aefa6cd331b364ad2bbc31652d025f5747d89cbb75576733dfdf8efe3e4d62 |