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

Holger Joukl Holger.Joukl at LBBW.de
Tue Oct 24 15:10:05 CEST 2006


Stefan Behnel <behnel_ml at gkec.informatik.tu-darmstadt.de> schrieb am
24.10.2006 00:23:54:

> Hi again,
>
> I rewrote the current recursive string printing implementation to use a
real
> iterator for attribute access, which also lead to much shorter code in
_Attrib
> (after a cleanup). This should remove the difference you see, although
moving
> towards the slower variant. However, if it worked, this means that the
> elements are immediately garbage collected, which is the right thing to
do
> from a memory perspective.
>
> Please test on your machine a) if the two code snippets still differ in
> performance and b) if the new implementation resulted in any
> noticeable slow down.

I can confirm
a) no performance difference between recursive element printing and "manual
element access" any more
b) no significant slow down
using the little timeit snippets for benchmarking.

> If you feel ambitious, take a look at the benchmark directory and try to
come
> up with a new benchmark suite "bench_objectify.py". The benchmark
framework
> makes new benchmarks extremely easy to write and the four test XML trees
> should be well suited for objectify already.

Will take a look.

Some more need for clarification:
If I understand correctly the lxml element proxy only speeds up things if
- I hold a python reference to the element object or
- a circular reference to the element in question prevents it from being
gc-ed
To speed up my usecase I could force-create and hold python references to
every node before
starting to operate on the tree.

Would it also be possible to modify objectify in a way that the lifespan of
the python _Element, once it has been instantiated, is tied to the
existence of the
underlying _c_node (xmlNode)?

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