[Zope-dev] difference between OOSet and OOTreeSet?
Chris Withers
chris at simplistix.co.uk
Fri Mar 2 02:42:20 EST 2007
Gary Poster wrote:
>
>> Okay, so I want a persistent, ordered sequence which is quick to find
>> items in and which doesn't re-store the whole sequence when an item is
>> inserted or removed.
>>
>> What should I be using?
>
> Ordered, as in sorted? Or ordered, as in user-determined order?
Ordered as in sorted, thankfully :-)
> If sorted, use BTreeSet (or the keys of a BTree).
As in OOTreeSet, right?
> Even though my
> assertion is right semantically for "Set", this is a BTreeSet, and I
> don't see this behavior changing ever.
*phew*
> No, it isn't a sequence, so
> `reversed` won't work, but `list` will always give you the same order.
Well, you can iterate over it...
Am I right in thinking I can get the reversed semantics I want by
negating the numeric part of insert?
s = OOTreeSet()
s.insert(-myvalue)
s.insert(-someothervalue)
...I just have to remember to re-negate them when I get 'em out?
> "Set" does not match the "doesn't re-store the whole sequence when an
> item is inserted or removed" requirement.
But OOTreeSet does, right?
> In both cases, IMO you'll want your data to be of homogenous types.
Yep, DateTimes all the way, or if you can't negate them, DateTime.timeTime's
cheers,
Chris
--
Simplistix - Content Management, Zope & Python Consulting
- http://www.simplistix.co.uk
More information about the Zope-Dev
mailing list