On Dec 10, 7:33 pm, Michael Bayer <[EMAIL PROTECTED]> wrote:
> this is the documented behavior and the comparator=operator.eq setting  
> is provided for exactly the purpose of efficiently comparing objects  
> which do implement an __eq__() that compares internal state, like that  
> of a dict (and who also don't provide identical pickles each time).    
> The default behavior of comparing pickles is to support user-defined  
> objects with mutable state which do not have an __eq__() method  
> provided.

Hi Michael,

It doesn't always work for the case that you mentioned.

class Foo:
  pass

d1 = Foo()
d1.Broker = 'A'
d1.F = 'B'
d1.Amt = 'A'

assert p.compare_values(p.copy_value(d1), d1)

If you use pickletools you can see that the variables of Foo are being
dumped in a different order in each of the cases below:

pickletools.dis(pickle.dumps(d1))
pickletools.dis(pickle.dumps(pickle.loads(pickle.dumps(d1))))
pickletools.dis(pickle.dumps(copy.copy(d1)))

The problem seems to be the assumption that copies of an object
produce identical pickles. Perhaps a better solution may be for
compare_values to use __eq__ by default if it exists otherwise compare
__dict__?

Also I don't agree that the current desired behaviour is documented.
See http://www.sqlalchemy.org/docs/05/types.html#types_standard_pickletype
and 
http://www.sqlalchemy.org/docs/05/sqlalchemy_types.html#docstrings_sqlalchemy.types_PickleType

Cheers,
Jon.
--~--~---------~--~----~------------~-------~--~----~
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