Skip to content

Clarify “Sequences also support slicing” in Data Model §3.2.5 #159180

Description

@smyarga

Documentation

https://docs.python.org/3.14/reference/datamodel.html#sequences

The section speaks about sequences in general, not only built-in ones(otherwise the qualifier “including built-in sequences” would be redundant). It consistently distinguishes universal properties from partial ones: negative subscripts are qualified as “Some sequences, including built-in sequences…”, and extended slicing as “Some sequences also support…”. Basic slicing, however, is stated unconditionally (“Sequences also support slicing”), although neither the glossary entry for sequence (https://docs.python.org/3.14/glossary.html) nor collections.abc.Sequence (https://docs.python.org/3.14/library/collections.abc.html#collections.abc.Sequence) requires it: a minimal class implementing only getitem/len passes isinstance(x, Sequence) but raises TypeError on slicing.

The proposed “Sequences may also support slicing (all built-in sequences do):...” wording would make the paragraph internally consistent.

Linked PRs

Activity

  1. added a commit that references this issue on Oct 11, 2026
  2. pochmann commented on Oct 12, 2026

    @pochmann
    Contributor

    Sequences support __getitem__, whose doc says:

    See the sequence documentation for the expected behavior, including handling slice objects and negative indices.

    So that sequence documentation seems to be the authority. And since it says that sequences support slicing, then if some "sequence" object doesn't support slicing, it's failing to do what's expected.

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

    docsDocumentation in the Doc dir

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions