Design thought for callbacks
Gregory Ewing
greg.ewing at canterbury.ac.nz
Tue Feb 24 00:20:29 EST 2015
Cem Karan wrote:
> I tend to structure my code as a tree or DAG of objects. The owner refers to
> the owned object, but the owned object has no reference to its owner. With
> callbacks, you get cycles, where the owned owns the owner.
This is why I suggested registering a listener object
plus a method name instead of a callback. It avoids that
reference cycle, because there is no long-lived callback
object keeping a reference to the listener.
--
Greg
More information about the Python-list
mailing list