On Tuesday April 26 2011 08:50:31 Martin Sandve Alnæs wrote: > On 26 April 2011 17:47, Martin Sandve Alnæs <marti...@simula.no> wrote: > > On 26 April 2011 17:08, Johan Hake <johan.h...@gmail.com> wrote: > >> On Tuesday April 26 2011 01:01:55 Martin Sandve Alnæs wrote: > >> > I'm not sure if this is safe or even solves anything. > >> > If there are circular references a.b = b; b.a = a, > >> > a.__del__ won't be called if the reference from > >> > b.a is still intact, since a.__del__ is called when > >> > the reference count of a goes to 0. Adding the > >> > __del__ function will also stop the cyclic reference > >> > detection in Python from cleaning up. That is my > >> > understanding after reading > >> > http://docs.python.org/reference/datamodel.html > >> > just now. Correct me if I'm wrong! > >> > >> If the above situation was correct you would be right. As it is now a > >> preprocessed form keeps a reference to form_data and form_data keeps a > >> reference to the preprocessed form => Ciruclar dependency. > > > > I.e. a.b = b; b.a = a. > > > > I tried to break that by deleting the preprocessed form from its > > form_data, > > > >> when the original form is deleted (not the preprocessed one.) When this > >> happens the preprocessed form will be deleted (I guess).
We now have: a.b = b b.a = a c.a = a when c is deleted it deletes b from a. So I guess it would work. > > A guess is not enough :) > > > > I don't feel confident about the __del__ patch. > > As you say, removing the circular references sounds like a better > > solution. Yes, that would be much better! > A possible tool for breaking the cycle: > http://docs.python.org/library/weakref.html Yes, that would help. Johan > Martin _______________________________________________ Mailing list: https://launchpad.net/~ffc Post to : ffc@lists.launchpad.net Unsubscribe : https://launchpad.net/~ffc More help : https://help.launchpad.net/ListHelp