A lazy-loading, fancy-sliceable iterable.
Project Links
Meta
Author: Daniel B. Allan
Classifiers
Development Status
- 4 - Beta
Programming Language
- Python :: 3
- Python :: 3.7
- Python :: 3.8
- Python :: 3.9
- Python :: 3.10
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]
Apr 07, 2022
1.1.0
Feb 14, 2019
1.0.0
Feb 01, 2019
1.0.0rc1
Nov 20, 2016
0.9.8
Jan 10, 2016
0.9.7
Nov 04, 2015
0.9.4
Oct 11, 2015
0.9.3
Jul 30, 2015
0.9.2
Jul 30, 2015
0.9.0
Wheel compatibility matrix
Files in release
No dependencies