Skip to content

Better document the terminating behaviour of PySeqIter_Type in the iter() docs #153739

Description

@jonathandung

Documentation

It is not exactly clear when the iterator returned by iter(seq) stops, where the type of seq implements __getitem__ . It was only by consulting the ABI docs that I found out it stops when IndexError is raised, and by experimenting in the console that only __length_hint__ on the iterator calls __len__ on seq if present and subtracts it by the number of items yielded. I believe this can be better documented, preferably in the iter() function documentation, which only mentions:

or it must support the sequence protocol (the __getitem__() method
with integer arguments starting at 0)

with no further explanation.

Metadata

Metadata

Assignees

No one assigned

    Labels

    docsDocumentation in the Doc dir

    Fields

    No fields configured for issues without a type.

    Projects

    Status
    Todo

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions