Victor Kryukov wrote:

> The following behavior is completely unexpected. Is it a bug or a by-
> design feature?
>
> ...
>
> from pickle import dumps
> from cPickle import dumps as cdumps
>
> print dumps('1001799')==dumps(str(1001799))
> print cdumps('1001799')==cdumps(str(1001799))

It's a feature, the behaviour is described in the documentation:

"""
Since the pickle data format is actually a tiny stack-oriented
programming language, and some freedom is taken in the encodings of
certain objects, it is possible that the two modules produce different
data streams for the same input objects. However it is guaranteed that
they will always be able to read each other's data streams
"""

>>> from pickle import dumps, loads
>>> from cPickle import dumps as cdumps, loads as cloads
>>> s = '1001799'
>>> s == cloads(dumps(s))
True
>>> s == loads(cdumps(s))
True

Regards,

-- 
.   Facundo
.
Blog: http://www.taniquetil.com.ar/plog/
PyAr: http://www.python.org/ar/


-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to