mirror of
https://github.com/python/cpython.git
synced 2025-07-24 03:35:53 +00:00
gh-100315: clarification to __slots__
docs. (GH-102621)
refer to tp_itemsize in discussion on "variable-length" built-in types
(cherry picked from commit 88c262c086
)
Co-authored-by: T <tnie@tuta.io>
This commit is contained in:
parent
0f46d42eb9
commit
1f7eb8fe6c
1 changed files with 4 additions and 2 deletions
|
@ -1944,8 +1944,10 @@ Notes on using *__slots__*
|
|||
descriptor directly from the base class). This renders the meaning of the
|
||||
program undefined. In the future, a check may be added to prevent this.
|
||||
|
||||
* Nonempty *__slots__* does not work for classes derived from "variable-length"
|
||||
built-in types such as :class:`int`, :class:`bytes` and :class:`tuple`.
|
||||
* :exc:`TypeError` will be raised if nonempty *__slots__* are defined for a
|
||||
class derived from a
|
||||
:c:member:`"variable-length" built-in type <PyTypeObject.tp_itemsize>` such as
|
||||
:class:`int`, :class:`bytes`, and :class:`tuple`.
|
||||
|
||||
* Any non-string :term:`iterable` may be assigned to *__slots__*.
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue