Skip to content

gh-61481: Document that memoryview, range, and slice cannot be subclassed - #153766

Open
soreavis wants to merge 2 commits into
python:mainfrom
soreavis:gh-61481-subclass-note
Open

soreavis wants to merge 2 commits into
python:mainfrom
soreavis:gh-61481-subclass-note

Conversation

@soreavis

@soreavis soreavis commented Jul 15, 2026 •

Copy link
Copy Markdown
Contributor

Among the built-in classes that can't be subclassed, only bool documents it. memoryview, range, and slice behave the same but say nothing, so it can only be found out by trying. Add the same note to those three.

The wording mirrors the existing bool entry, minus the "further" that applies only to bool (which subclasses int). Confirmed at tip: subclassing each raises TypeError (they lack Py_TPFLAGS_BASETYPE), while int and list allow it.

This is the note the issue author proposed, and the thread confirmed all four are intentional rather than oversights. The types module classes mentioned in the issue are documented separately and are out of scope here.

…subclassed

Among the built-in classes that can't be subclassed, only bool documents
it. memoryview, range, and slice behave the same but say nothing, so it
can only be found out by trying. Add the same note to those three.

The wording mirrors the existing bool entry, minus the "further" that
applies only to bool (which subclasses int).
@read-the-docs-community

read-the-docs-community Bot commented Jul 15, 2026 •

Copy link
Copy Markdown

@bedevere-app bedevere-app Bot added the type-feature A feature request or enhancement label Oct 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting review docs Documentation in the Doc dir skip news type-feature A feature request or enhancement

Projects

Status: Todo

Development

Successfully merging this pull request may close these issues.

1 participant