Hi all,

On 5/22/07, Julien Cigar <[EMAIL PROTECTED]> wrote:
> yes of course [1,2,3] is different than [3,2,1] (hopefully), I was
> talking for InstrumentedList, not tuple or list or ...

IMO InstrumentedList should definately have the same semantics as a
list - what you're talking about is to make it behave partially like a
set.

> Anyway, I've used  sorted(MyInstrumentList...) ==
> sorted(MyInstrumentList2 or MyTuple or ...) ... which works :-)

Given the use case
>>> a = Invasive.get(67).habitats
>>> b = Invasive.get(57).habitats

you could add an "order_by" to the habitats relation - which would
give you the list in the same order every time. Of course it will not
maintain that order if you .append() or .remove() items before making
the comparison.

If you are pressing for speed, you could do two things:

a) before checking if sorted(a) == sorted(b) - see if they're the same
length. If they're not, there's no need to sort them, you know they'll
be different from each other.

b) see if using a set (or a dict if you don't have python 2.4, using
only the keys) is faster than doing the two sorts and then comparing

Arnar

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to