New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Clarification in the __slots__
documentation
#100315
Comments
The interactive REPL is always useful for discovering some of the answers to questions like this: >>> class Foo(int):
... __slots__ = 'bar',
...
Traceback (most recent call last):
File "<string>", line 1, in <module>
TypeError: nonempty __slots__ not supported for subtype of 'int'
>>> class Foo(str):
... __slots__ = 'bar',
...
>>> For your first question, we could possibly change the wording to
For your second question: I don't know what's being referred to by "variable-length builtin types", so I agree that the wording there is a little opaque. |
You can check if any type is variable length or not from python with |
Is this definition given anywhere in the documentation? If so, we could maybe link to it from the |
Looks like the best place to link to might be https://docs.python.org/3/c-api/typeobj.html#c.PyTypeObject.tp_itemsize. Hardly beginner-friendly, but probably better than no link at all (and I think it's good to keep the section on |
Yeah, that's the best place I can find too. |
kwsp commentedDec 17, 2022
Documentation
https://docs.python.org/3/reference/datamodel.html#notes-on-using-slots
One of the bulletpoints:
Points to clarify:
str
one of them?The text was updated successfully, but these errors were encountered: