[ZODB-Dev] Iterating through BTreeItems

Greg Ward gward@mems-exchange.org
Thu, 24 May 2001 19:24:57 -0400


On 24 May 2001, Jim Fulton said:
> In general. the repr would be counter productive, since there are
> typically lots of items. I'd happily accept a patch (or maybe 
> later a checkin) for a repr that did the normal thing when there
> weren't many values and then maybe showed some elided values when
> there are more than a certain amount.

I don't think the repr() of a BTreeItems should show the actual items,
regardless of length.  For a typical BTree, there are probably hundreds
or thousands or more items, so repr()'ing them like an ordinary Python
sequence is madness (or "counter-productive" if you like ;-).
Furthermore, the rules shouldn't change based on size: that makes
something as simple as repr() appear random and unpredictable.

However, I would love to see
  <BTreeItems object at 0x831b208: 549 items>
instead of
  <BTreeItems object at 0x831b208>
and I bet it wouldn't be too hard either.  ;-)

Come to think of it, it would also be nice to see
  <BTree object at 0x831b208: 549 items>

        Greg
-- 
Greg Ward - software developer                gward@mems-exchange.org
MEMS Exchange                            http://www.mems-exchange.org