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.
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 Distribution
slicerator-1.0.0.tar.gz
(26.3 kB
view details)
Built Distribution
File details
Details for the file slicerator-1.0.0.tar.gz
.
File metadata
- Download URL: slicerator-1.0.0.tar.gz
- Upload date:
- Size: 26.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.21.0 setuptools/40.7.2 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.6.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 18e60393e6765ca96986f801bbae62a617a1eba6ed57784e61b165ffc7dc1848 |
|
MD5 | 1d225b86de262c487ccf9a12ac2f65ab |
|
BLAKE2b-256 | 9ea156dac5f3ddc300813d3f247a7af6a585a6122c400825dbc7192b0183fa83 |
Provenance
File details
Details for the file slicerator-1.0.0-py3-none-any.whl
.
File metadata
- Download URL: slicerator-1.0.0-py3-none-any.whl
- Upload date:
- Size: 9.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.21.0 setuptools/40.7.2 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.6.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 63f12bec440b05ffb9a5b17812c835eb4631c0fbb1017421d9638378cfb93487 |
|
MD5 | e35204317f5b52f629187ad0ad781d23 |
|
BLAKE2b-256 | 75aefe46f5371105508a209fe6162e7e7b11db531a79d2eabcd24566b8b1f534 |