[ZODB-Dev] BTree mutating iteration

Tim Peters tim at zope.com
Fri Feb 20 17:41:30 EST 2004


[Bob Ippolito]
> I see, it would make sense to rename BTree's items to iteritems, and
> deprecate the items method then.

In ZODB 3.3, both methods exist.  To avoid other confusions, iteritems() has
to play nice with Python's new-in-2.2 iteration protocol, which didn't exist
when BTree.items() was first written.  In the other direction, the lazy
iterators currently returned (in the cases they are returned) support a ton
of stuff not covered by the iteration protocol (like indexing and slicing):
items() and iteritems() aren't the same thing.

Another confusion is that while BTree items/keys/values return a funky "lazy
iterator", Bucket items/keys/values return Python lists, and while code
shouldn't rely on this implementation detail, I know for a fact that lots of
code does.  In 3.3 the new iter+items/keys/values return iterators (not
lists) for all the Bucket and Set -based container types.




More information about the ZODB-Dev mailing list