[lxml-dev] [lxml][objectify] optimization questions

Holger Joukl Holger.Joukl at LBBW.de
Tue Oct 24 14:13:37 CEST 2006



Hello Stefan,

Stefan Behnel <behnel_ml at gkec.informatik.tu-darmstadt.de> schrieb am
23.10.2006 22:53:51:

> I think I can give an answer here. The difference lies in the two cleanup
> modes in the Python interpreter: GC and ref counting. Ref-counted objects
> disappear immediately after loosing the last reference, however, when
there
> are circular references between elements, the GC is required to clean
them up.
> These objects can be garbage collected at any time, but they are usually
kept
> until there is a good opportunity to clean them up, i.e. enough time has
> passed to merit the GC overhead or memory is filling up so it has to run.
>
> Now, the way recursive dumping is currently implemented instantiates an
> additional object for each element: _Attrib. This generates circular
> references between the element and its attribute proxy which enforces use
of
> the GC instead of the normal ref-count algorithm. So elements that were
> recursively printed stay alive until the next run of the GC. Elements
that do
> not have an _Attrib dictionary proxy can be deleted when ref-
> counting them out.
>
> You should be able to reproduce the behaviour observed after recursive
> printing with elements for which you called ".attrib".

Thanks for this good explanation! This of course also explains why my
experiments
with an additional "visit" function (a stripped down _dump, essentially)
only worked when there was a call to element.items() included.

Holger


Der Inhalt dieser E-Mail ist vertraulich. Falls Sie nicht der angegebene
Empfänger sind oder falls diese E-Mail irrtümlich an Sie adressiert wurde,
verständigen Sie bitte den Absender sofort und löschen Sie die E-Mail
sodann. Das unerlaubte Kopieren sowie die unbefugte Übermittlung sind nicht
gestattet. Die Sicherheit von Übermittlungen per E-Mail kann nicht
garantiert werden. Falls Sie eine Bestätigung wünschen, fordern Sie bitte
den Inhalt der E-Mail als Hardcopy an.

The contents of this  e-mail are confidential. If you are not the named
addressee or if this transmission has been addressed to you in error,
please notify the sender immediately and then delete this e-mail.  Any
unauthorized copying and transmission is forbidden. E-Mail transmission
cannot be guaranteed to be secure. If verification is required, please
request a hard copy version.




More information about the lxml-dev mailing list