[lxml-dev] 2.0 ElementTree 1.3 compat: getiterator
Stefan Behnel
stefan_ml at behnel.de
Wed Oct 24 17:42:45 CEST 2007
jholg at gmx.de wrote:
>>> I for one think it counter-intuitive for getiterator() to return a list,
>>> so I think lxml got that right in the first place.
>>
>> I would agree from the point of view of the method name, but disagree for
>> reasons of API redundancy and backwards compatibility.
>
> I see, but from an lxml point of view we are actually losing backwards compatibility, aren't we ;-)
Sure, but this is 2.0 :)
I actually hope that the change isn't as big as it sounds. In most cases, a
list behaves as good as any other iterable, think of
for child in el.getiterator()
Obviously, the performance is different in some use cases, but that will only
matter if you are interested in, say, 5 out of 100 elements, or if you iterate
over really big trees where you cannot afford having all proxies in memory.
Fredriks original intention was to deprecate getiterator() in favour of iter()
and I think reverting it to returning a list (as ET did for ages) is a better
alternative here.
Anyway, as I said, I'm currently waiting for Fredrik to implement this in ET
to make the change official in a new release - then we can say: sorry, we're
only following ET's evolution... :)
Stefan
More information about the lxml-dev
mailing list