Clarify __subclasses__ behavior in slotted classes

Ref #691,#407
This commit is contained in:
Hynek Schlawack 2020-09-28 11:16:21 +01:00
parent a5fe89ccd9
commit b0d2d92787
1 changed files with 3 additions and 0 deletions

View File

@ -87,6 +87,9 @@ Glossary
- Since it's currently impossible to make a class slotted after it's been created, ``attrs`` has to replace your class with a new one. - Since it's currently impossible to make a class slotted after it's been created, ``attrs`` has to replace your class with a new one.
While it tries to do that as graciously as possible, certain metaclass features like ``__init_subclass__`` do not work with slotted classes. While it tries to do that as graciously as possible, certain metaclass features like ``__init_subclass__`` do not work with slotted classes.
- The `class.__subclasses__` attribute needs a garbage collection run (which can be manually triggered using `gc.collect`), for the original class to be removed.
See issue `#407 <https://github.com/python-attrs/attrs/issues/407>`_ for more details.
.. [#pypy] On PyPy, there is no memory advantage in using slotted classes. .. [#pypy] On PyPy, there is no memory advantage in using slotted classes.
.. [#pypyweakref] On PyPy, slotted classes are naturally weak-referenceable so ``weakref_slot=False`` has no effect. .. [#pypyweakref] On PyPy, slotted classes are naturally weak-referenceable so ``weakref_slot=False`` has no effect.