mirror of
https://github.com/python/cpython.git
synced 2025-11-02 03:01:58 +00:00
[doc] Mention __slots__ behavior in weakref.rst (GH-21061)
It took me longer than I expected to figure out why a random class I dealt with didn't support weak references. I believe this addition will make the __slots__/weakref interaction more discoverable to people having troubles with this. (Before this patch __slots__ was not mentioned in weakref documentation even once). Co-authored-by: Łukasz Langa <lukasz@langa.pl>
This commit is contained in:
parent
682aecfdeb
commit
b24b47e643
1 changed files with 4 additions and 0 deletions
|
|
@ -88,6 +88,10 @@ support weak references but can add support through subclassing::
|
||||||
Extension types can easily be made to support weak references; see
|
Extension types can easily be made to support weak references; see
|
||||||
:ref:`weakref-support`.
|
:ref:`weakref-support`.
|
||||||
|
|
||||||
|
When ``__slots__`` are defined for a given type, weak reference support is
|
||||||
|
disabled unless a ``'__weakref__'`` string is also present in the sequence of
|
||||||
|
strings in the ``__slots__`` declaration.
|
||||||
|
See :ref:`__slots__ documentation <slots>` for details.
|
||||||
|
|
||||||
.. class:: ref(object[, callback])
|
.. class:: ref(object[, callback])
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue