-
-
Notifications
You must be signed in to change notification settings - Fork 409
Closed
Description
I'm excited to see that the latest attrs version 23.2.0 now supports using cached_property in combination with slotted classes 🥇👍🏼 I was about to enable this feature in my code base but then noticed the following issue: the garbage collection step described here no longer seems to work. I haven't checked how exactly the use of cached_property was enabled, but the applied mechanism seems to keep some references to the original classes and thus messes with the garbage collector, which I think is an undesired side-effect.
Here a minimal example to reproduce the issue:
import gc
from functools import cached_property
from attrs import define
@define
class Base:
pass
@define
class SubClass(Base):
@cached_property
def value(self) -> int:
return 0
gc.collect()
print(Base.__subclasses__())With the cached_property decorator, this gives the following output:
[<class '__main__.SubClass'>, <class '__main__.SubClass'>]while removing it yields the desired result:
[<class '__main__.SubClass'>]Metadata
Metadata
Assignees
Labels
No labels