> > [...]
> > 0 $ (PYTHONPATH=build/lib.linux-x86_64-3.6/ python3 -m timeit -r 5 -n
> > 1000000 --setup 'from lxml import etree, objectify' 'root =
> > objectify.XML("<root><x>1000000</x><y>1000_000</y></root>")')
> > 1000000 loops, best of 5: 17.1 usec per loop
> >
> > (No it's not faster, this is just a lucky timeit run - but it's
> > absolutely in the same ballpark as before)
>
> … except that this is not a good benchmark – it doesn't call the code that was
> changed. :)

Oh boy. Yes of course :-/, thanks for noting.

> You could use `objectify.XML("…").y' to get an actual element tested and
> instantiated.
>
> I wouldn't expect much of a difference, though. Parsing will take most of the 
> time,
> then actually instantiating the element object. Testing the value should be 
> quick in
> comparison (and even quicker now).


$ (for PYTHONPATH in "$LXML462" "$TRUNK"; do (export PYTHONPATH; python3 
-c'from lxml import etree, objectify; print(etree.__version__); root = 
objectify.XML("<root><x>1000_000.123</x><y>1000_000</y><z>1000_000_</z></root>");
 print(objectify.dump(root))'); echo; done;)
4.6.2
root = None [ObjectifiedElement]
    x = 1000000.123 [FloatElement]
    y = 1000000 [IntElement]
    z = '1000_000_' [StringElement]

4.6.3
root = None [ObjectifiedElement]
    x = '1000_000.123' [StringElement]
    y = '1000_000' [StringElement]
    z = '1000_000_' [StringElement]

$ (for EXPR in root.x root.y root.z; do echo "=== $EXPR"; for PYTHONPATH in 
"$LXML462" "$TRUNK"; do (export PYTHONPATH; python3 -c'from lxml import etree; 
print(etree.__version__)'; python3 -m timeit -r 10 -n 1000000 --setup 'from 
lxml import etree, objectify; root = 
objectify.XML("<root><x>1000_000.123</x><y>1000_000</y><z>1000_000_</z></root>")'
 "$EXPR"); echo; done; done;)
=== root.x
4.6.2
1000000 loops, best of 10: 2.69 usec per loop

4.6.3
1000000 loops, best of 10: 2.53 usec per loop

=== root.y
4.6.2
1000000 loops, best of 10: 1.26 usec per loop

4.6.3
1000000 loops, best of 10: 2.57 usec per loop

=== root.z
4.6.2
1000000 loops, best of 10: 3.08 usec per loop

4.6.3
1000000 loops, best of 10: 2.54 usec per loop

Holger







Landesbank Baden-Wuerttemberg
Anstalt des oeffentlichen Rechts
Hauptsitze: Stuttgart, Karlsruhe, Mannheim, Mainz
HRA 12704
Amtsgericht Stuttgart
HRA 4356, HRA 104 440
Amtsgericht Mannheim
HRA 40687
Amtsgericht Mainz

Die LBBW verarbeitet gemaess Erfordernissen der DSGVO Ihre personenbezogenen 
Daten.
Informationen finden Sie unter https://www.lbbw.de/datenschutz.
_______________________________________________
lxml - The Python XML Toolkit mailing list -- lxml@python.org
To unsubscribe send an email to lxml-le...@python.org
https://mail.python.org/mailman3/lists/lxml.python.org/
Member address: arch...@mail-archive.com

Reply via email to