skillfed

slicerator

A lazy-loading, fancy-sliceable iterable.

slicerator v1.1.0 337.8K downloads/30d#7,444 on PyPI18
Permissive license BSD AGING released

What it is and what it does

Slicerator is a decorator-based wrapper that turns a class with `__getitem__` and `__len__` methods into a lazy-loading, reusable iterable. Unlike a generator, a Slicerator object can be indexed multiple times and has a known length; unlike a list, it defers data loading until you actually access an element. You decorate your data-loading class with `@Slicerator.from_class`, and the wrapper automatically handles slices (e.g., `obj[::2]`), integer lists, and boolean masks—all without loading data until the final indexing operation.

The package is designed for scenarios where you want the convenience of array-like indexing and slicing but need to avoid loading everything into memory upfront. It chains slicing operations lazily, so `obj[::2][1:]` computes the combined slice without materializing intermediate results. With no runtime dependencies and a pure-Python implementation, it integrates easily into existing projects.

Use it for:

  • Wrapping a file reader or database query class to support array-like slicing without loading all records into memory.
  • Building lazy-loading image or video frame sequences that only decode frames when indexed.
  • Creating a filtered or transformed view of a dataset that defers computation until specific elements are accessed.
  • Chaining multiple slice operations on large datasets to avoid intermediate materialization.

Worth the install?

AI-flagged interpretation of the facts on this page — verify before relying

Slicerator wraps a class's `__getitem__` method to create a lazy-loading iterable that supports fancy indexing—slices, integer lists, and boolean masks—while deferring data loading until access.

Yes, if you need lazy-loading with fancy indexing and have a class-based data source. The low install friction, permissive license, and zero runtime dependencies make it a lightweight addition. However, the package is aging—latest release 2022-04-07—so verify it meets your Python version and use case before committing.

Install

slicerator on PyPI

pip

pip install slicerator

uv

uv add slicerator

poetry

poetry add slicerator

Installing slicerator

Before you install

Low friction: pure Python wheel with no runtime dependencies. Maintenance is aging—last release was 2022-04-07 and the repository has not been updated since 2025-06-30, though it remains unarchived.

License in practice

BSD license is permissive, allowing commercial and private use with minimal restrictions.

Quickstart

from slicerator import Slicerator

@Slicerator.from_class
class MyLazyLoader:
    def __getitem__(self, i):
        return thing
    def __len__(self):
        return number_of_things

a = MyLazyLoader()
s1 = a[::2]
data = s1[0]

Verify before relying

  • Whether the package is actively maintained or in maintenance-only mode given the gap between latest release and recent commits.
  • Performance characteristics when chaining multiple slicerator operations or working with very large datasets.

Package facts

License BSD (permissive)
Python support not specified
Install friction low — pure-Python wheel
Runtime dependencies none
Maintenance aging — 1,590 days since the last release
Last repo commit
First released
Downloads 337,812/month — #7,444 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: slicerator-1.1.0-py3-none-any.whl

Development Status :: 4 - BetaProgramming Language :: Python :: 3Programming Language :: Python :: 3.10Programming Language :: Python :: 3.7Programming Language :: Python :: 3.8Programming Language :: Python :: 3.9

Tags

lazy loading iterablefancy slicing generatorreusable generator with lengthdeferred data loadingslice-aware iterator wrapper
lazy-loadingiterator-wrapper

More Software Development packages