Brandt Bucher <[email protected]> added the comment:
> Maybe I am missing something but we could mark them as having GC support
> unconditionally but still leave them untracking and unconditionally add a
> tracking call on setattribute.
Hm, I’m not sure that would be enough. Consider the case of a class that
registers its instances in a collection of some sort:
while True:
class D:
__slots__ = ()
registry = []
def __init__(self):
self.registry.append(self)
for i in range(100):
D() and None # Suppress REPL output.
del D
This is probably more common (and problematic) than my example above.
At the same time, I agree that it’s not *ideal* to track all of these objects
automatically. Anyone setting __slots__ is probably planning on creating lots
of “cheap” instances. If they do accidentally create cycles, though, I feel the
memory hit then would be worse than any collection overhead.
I’m just not sure I see a way to fix this without tracking them all.
----------
_______________________________________
Python tracker <[email protected]>
<https://bugs.python.org/issue41984>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com