marshal bug?

Gabriel Genellina gagsl-py2 at yahoo.com.ar
Fri Sep 28 10:04:21 CEST 2007


En Fri, 28 Sep 2007 04:26:39 -0300, Anurag <anuraguniyal at gmail.com>  
escribi�:

> Now is there a easy way to by pass it (hack around it)
> I tried various options but all fail e.g.
> i= 123; marshal.dumps("%d"%123) != marshal.dumps("%d"%i)

You can't. Don't use marshal to compare objects. You appear to assume that  
two objects that compare equal, should have the same marshalled  
representation, and that is simply not true.

py> [1, 2.0, 3+0j, "4"] == [1.0, 2+0j, 3, u"4"]
True

> So maybe I have to change all my code to use pickle, which also
> consumes for memory per string.

Neither marshal nor pickle guarantee that equal objects have equal  
representations, so in this regard pickle won't help either.
Maybe if you explain what you really want to do someone could suggest a  
solution.

-- 
Gabriel Genellina




More information about the Python-list mailing list