pypaginate.domain.fast_pages

Fast page construction using msgspec (optional).

When msgspec is installed, provides near-zero-overhead page construction via msgspec.Struct instead of Pydantic BaseModel. Duck-types as OffsetPage/CursorPage with .model_dump() and .to_pydantic() for compatibility.

Classes

FastCursorPage

Lightweight cursor page — near-zero construction cost.

FastOffsetPage

Lightweight offset page — near-zero construction cost.

Module Contents

class pypaginate.domain.fast_pages.FastCursorPage

Bases: msgspec.Struct

Lightweight cursor page — near-zero construction cost.

model_dump() dict[str, Any]

Convert to dict (Pydantic-compatible API).

model_dump_json() bytes

Convert to JSON bytes (fast path via msgspec).

to_pydantic() Any

Convert to a real Pydantic CursorPage.

class pypaginate.domain.fast_pages.FastOffsetPage

Bases: msgspec.Struct

Lightweight offset page — near-zero construction cost.

model_dump() dict[str, Any]

Convert to dict (Pydantic-compatible API).

model_dump_json() bytes

Convert to JSON bytes (fast path via msgspec).

to_pydantic() Any

Convert to a real Pydantic OffsetPage.