As the question says, what would be the difference between:
x.getiterator()
and x.iter()
, where x
is an ElementTree or an Element? Cause it seems to work for both, I have tried it.
If I am wrong somewhere, correct me please.
The Python documentation for ElementTree states that the getiterator()
method has been deprecated starting with version 2.7 and says to use Element.iter()
. The lxml API documentation states the same but also mentions that the implementation of getiterator()
in lxml diverges from the original ElementTree behavior.
Interestingly enough the documentation also states that "If you want an efficient iterator, use the tree.iter() method instead". Note the word "efficient", which leads me to believe there is most certainly a difference in implementation between getiterator()
and iter()
, but without checking out the source I can't be 100% sure.
Anyhow, if something has been deprecated it's clear they don't want you to use it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With