Skip to content

GlyphBuffer.__getitem__ doesn't support slices #10

Description

@hasanzakeri

Today __getitem__ only accepts integers; gbuf[1:3] raises TypeError: index must be int. Pythonic users will expect slicing to work.

Suggested behavior: a slice returns a list[tuple[GlyphInfo, GlyphPosition]] (matches what list(gbuf)[1:3] already produces, just without materializing the full buffer).

Implementation: extend __getitem__ in src/glyph.rs to accept Bound<'_, PyAny> and dispatch on PySlice vs int. Use slice.indices(len) to normalize.

Out-of-scope items it does NOT need to support: assignment (gbuf[i] = ...), step != 1 (can support trivially), negative-step slices.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions