Re: lxml.objectify interprets <x>1000_000</x> as int in Python>3.6 - should it?

Works great! Nice touch with the fuzzy tester ;-). Some super-simple "benchmarking" indicates there's no noticeable slowdown: # we're on 4.6.2 so far, haven't bothered to update to latest 4.6.3 release 0 $ (PYTHONPATH=$PYTAF_HOME/2020-Q3-V2/lib/python3.6/site-packages/ python3 -c 'from lxml import etree, objectify; print(etree.__version__); root = objectify.XML("<root><x>1000000</x><y>1000_000</y></root>"); print(objectify.dump(root))') 4.6.2 root = None [ObjectifiedElement] x = 1000000 [IntElement] y = 1000000 [IntElement] 0 $ (PYTHONPATH=$PYTAF_HOME/2020-Q3-V2/lib/python3.6/site-packages/ 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.5 usec per loop # current gh version (version number still 4.6.3, from latest release) 0 $ (PYTHONPATH=build/lib.linux-x86_64-3.6/ python3 -c 'from lxml import etree, objectify; print(etree.__version__); root = objectify.XML("<root><x>1000000</x><y>1000_000</y></root>"); print(objectify.dump(root))') 4.6.3 root = None [ObjectifiedElement] x = 1000000 [IntElement] y = '1000_000' [StringElement] 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) Thanks a lot! 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.

Holger.Joukl@LBBW.de schrieb am 10.09.21 um 16:23:
… except that this is not a good benchmark – it doesn't call the code that was changed. :) 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). Stefan

Holger.Joukl@LBBW.de schrieb am 10.09.21 um 16:23:
… except that this is not a good benchmark – it doesn't call the code that was changed. :) 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). Stefan
participants (2)
-
Holger.Joukl@LBBW.de
-
Stefan Behnel