Stefan Behnel wrote:
Fredrik Lundh wrote:
Stefan Behnel wrote:
in the end you will not be very impressed. One of the results of the benchmarks is that ElementTree beats lxml sometimes and that cElementTree beats lxml in most cases.
can you post a copy of the results ?
Here you go. [...]
Hi, just wanted to add a note that the results of the comparison actually do depend on what benchmarks you run. Here's an example where lxml is pretty competitive. I'll add more benchmarks to the script over time. def bench_remove_children(self, root): for child in root: root.remove(child) def bench_remove_children_reversed(self, root): for child in reversed(root[:]): root.remove(child) Stefan etree remove_nodes (T1 ) 7.1806 7.8207 7.5744 msec/pass, best: 7.1806 ElementTree remove_nodes (T1 ) 9.9351 10.3656 10.2434 msec/pass, best: 9.9351 cElementTree remove_nodes (T1 ) 1.1753 1.1938 1.1930 msec/pass, best: 1.1753 etree remove_nodes (T2 ) 10.7585 11.1049 11.0373 msec/pass, best: 10.7585 ElementTree remove_nodes (T2 ) 163.0597 163.6652 163.5988 msec/pass, best: 163.0597 cElementTree remove_nodes (T2 ) 4.5629 4.6345 4.6852 msec/pass, best: 4.5629 etree remove_nodes (T3 ) 0.4624 0.4984 0.4635 msec/pass, best: 0.4624 ElementTree remove_nodes (T3 ) 3.1772 3.1977 3.1922 msec/pass, best: 3.1772 cElementTree remove_nodes (T3 ) 0.3280 0.3293 0.3732 msec/pass, best: 0.3280 etree remove_nodes (T4 ) 0.1855 0.1881 0.2297 msec/pass, best: 0.1855 ElementTree remove_nodes (T4 ) 0.4550 0.4557 0.4541 msec/pass, best: 0.4541 cElementTree remove_nodes (T4 ) 0.0217 0.0215 0.0216 msec/pass, best: 0.0215 etree remove_nodes_reversed (T1 ) 8.6140 7.7091 7.2880 msec/pass, best: 7.2880 ElementTree remove_nodes_reversed (T1 ) 19.3782 18.9275 18.9883 msec/pass, best: 18.9275 cElementTree remove_nodes_reversed (T1 ) 2.2662 2.2573 2.2869 msec/pass, best: 2.2573 etree remove_nodes_reversed (T2 ) 12.0817 12.6200 13.0714 msec/pass, best: 12.0817 ElementTree remove_nodes_reversed (T2 ) 648.7812 647.7359 671.5900 msec/pass, best: 647.7359 cElementTree remove_nodes_reversed (T2 ) 12.8756 12.9411 12.8823 msec/pass, best: 12.8756 etree remove_nodes_reversed (T3 ) 0.3564 0.3560 0.3582 msec/pass, best: 0.3560 ElementTree remove_nodes_reversed (T3 ) 4.4038 4.4472 4.3877 msec/pass, best: 4.3877 cElementTree remove_nodes_reversed (T3 ) 0.4653 0.4736 0.4737 msec/pass, best: 0.4653 etree remove_nodes_reversed (T4 ) 0.1996 0.1971 0.1951 msec/pass, best: 0.1951 ElementTree remove_nodes_reversed (T4 ) 1.6460 1.6219 1.6266 msec/pass, best: 1.6219 cElementTree remove_nodes_reversed (T4 ) 0.0534 0.0503 0.0538 msec/pass, best: 0.0503