pypaginate.dataset

Resident in-memory dataset: filter + sort + paginate in one call.

Dataset marshals a sequence of items ONCE and answers repeated paginated queries. When the native paginate-core engine is installed it runs the whole filter -> sort -> paginate pipeline in a single native call (returning page indices); otherwise it falls back to the pure-Python in-memory backends. Both paths return an identical OffsetPage, so the result never depends on whether the native extension is present.

This complements the top-level pypaginate.paginate() — which paginates an already-prepared sequence — by folding filtering and sorting into the same call: the “powerful core, thin adapter” shape, where the engine does the work and the host only selects rows by the returned indices.

Classes

Dataset

An in-memory dataset queried by one-call filter + sort + paginate.

Module Contents

class pypaginate.dataset.Dataset(items: collections.abc.Sequence[ItemT])

Bases: Generic[ItemT]

An in-memory dataset queried by one-call filter + sort + paginate.

paginate(params: pypaginate.domain.params.OffsetParams, *, filters: collections.abc.Sequence[pypaginate.domain.specs.FilterSpec] | None = None, sorting: collections.abc.Sequence[pypaginate.domain.specs.SortSpec] | None = None, search: pypaginate.domain.specs.SearchSpec | None = None) pypaginate.domain.pages.OffsetPage[ItemT]

Filter, then sort, then offset-paginate; return an OffsetPage.

Uses the native one-call pipeline when available and the query is natively supported (no search); otherwise the pure-Python backends. Both paths produce the same page. Multiple filters are combined with AND (mirroring the in-memory filter backend); grouped filters are not accepted here — use the backend API for those.