On Sunday, 29 January 2012 20:05:26 UTC+8, Willem Jan Palenstijn wrote: > > On Sat, Jan 28, 2012 at 04:36:17PM +0100, Julien Puydt wrote: > > Le 29/01/2012 12:13, Willem Jan Palenstijn a �crit : > > >So this is the same issue with char being unsigned on your platform. > > >Specifically, it seems the corresponding __reduce__ function converts a > char > > >array into a list of python ints, which has range 0-255 for you, > instead of the > > >-128-127 on x86. And the unpickle function has the opposite issue. > > > > > >I wonder how many of these are around, and if there is any general fix > for > > >them. > > > > Well, if there is a nice inheritance graph, there's hope fixing the > > base class will maket the rest just go smooth. > > > > Now, to fix the base class... If the goal is to take a "char" on one > > platform and turn it into a "char" on another, then it's a lost > > battle. > > Which base class do you mean exactly? > > > What are those "char" really encoding? If they are really "foo", > > then turning a "foo" on one platform into a "foo" on another might > > not be impossible! > > In this particular case, it seems Matrix_mod2_dense's __reduce__ > serializes its > data by compressing it as a black/white PNG image. So it's really just a > raw > byte stream. > and then it does (line 1750):
cdef char *buf = <char*>gdImagePngPtr(im, &size) data = [buf[i] for i in range(size)] and this data goes into the pickle. No wonder it gets different on different platforms! Dima > -Willem Jan > > -- To post to this group, send an email to sage-devel@googlegroups.com To unsubscribe from this group, send an email to sage-devel+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-devel URL: http://www.sagemath.org