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.
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
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 Distributions
slicerator-0.9.7.zip
(25.3 kB
view details)
slicerator-0.9.7.tar.gz
(21.4 kB
view details)
File details
Details for the file slicerator-0.9.7.zip.
File metadata
- Download URL: slicerator-0.9.7.zip
- Upload date:
- Size: 25.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
364a1ecdfd68c885a5835704f5207c5ad1e986d6066beeb1cde3e6a55c92cad9
|
|
| MD5 |
53e6c0fcbb701b009e79240f7c7955db
|
|
| BLAKE2b-256 |
0b3b261ae11c023e5d0a6ccd8d0165e1bc9d5639e14c71dfa9fd3f4050e44b70
|
File details
Details for the file slicerator-0.9.7.tar.gz.
File metadata
- Download URL: slicerator-0.9.7.tar.gz
- Upload date:
- Size: 21.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
efc5c8a1f5f65fd8e961fa3109c4e93c55be83edfcec0965dc76fa67b6fd5116
|
|
| MD5 |
2730493509da7c269a5afac80bcfbedb
|
|
| BLAKE2b-256 |
ea138f7b9f0aadce86d632a7cbad01221d3f7dc126ef857eb95164917a006b01
|