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 details)
Built Distribution
File details
Details for the file slicerator-1.1.0.tar.gz
.
File metadata
- Download URL: slicerator-1.1.0.tar.gz
- Upload date:
- Size: 38.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.0 CPython/3.10.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 44010a7f5cd87680c07213b5cabe81d1fb71252962943e5373ee7d14605d6046 |
|
MD5 | 30abc2b1d533424706182b78f6f17833 |
|
BLAKE2b-256 | 0c52f38586b82b2935f8b59a09b0a79c545a22ed062e728c9418bafeb51f61e0 |
File details
Details for the file slicerator-1.1.0-py3-none-any.whl
.
File metadata
- Download URL: slicerator-1.1.0-py3-none-any.whl
- Upload date:
- Size: 10.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.0 CPython/3.10.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 167668d48c6d3a5ba0bd3d54b2688e81ee267dc20aef299e547d711e6f3c441a |
|
MD5 | 8ac2736c328a5a9757cde7b5cee193f3 |
|
BLAKE2b-256 | e8aefa6cd331b364ad2bbc31652d025f5747d89cbb75576733dfdf8efe3e4d62 |