You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Clarify “Sequences also support slicing” in Data Model §3.2.5 #159180
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.
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.
Activity
pythongh-159180: Clarify that basic slicing is not universal for sequ…
pochmann commentedon Oct 12, 2026
Sequences support
__getitem__, whose doc says: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.