[issue5518] cPickle produces inconsistent output

2009-03-20 Thread rb

rb rb-os...@justgohome.co.uk added the comment:

Martin,

Sorry, I don't follow. I realise that the refcounts will be different;
but pickling an object should surely be independent of the refcount as
there is no need to include the refcount in the output?

What other way (using pickle or not) can I convert a generic immutable
Python object to a string to use as a key in external storage?

Currently the documentation points out that the output may be different
between pickle and cPickle which implies that the output will be
consistent for a single module.

If pickle is not required to produce consistent output for the same
input (and refcount isn't really part of the input in this case; it is 
a side issue) than can this be documented?

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue5518
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue5518] cPickle produces inconsistent output

2009-03-20 Thread Benjamin Peterson

Benjamin Peterson benja...@python.org added the comment:

pickle is designed to provide persistent storage, not create keys for
objects. Changes to the format are fine as long as they are compatible.

--
nosy: +benjamin.peterson
status: pending - closed

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue5518
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue5518] cPickle produces inconsistent output

2009-03-20 Thread Martin v. Löwis

Martin v. Löwis mar...@v.loewis.de added the comment:

 Sorry, I don't follow. I realise that the refcounts will be different;
 but pickling an object should surely be independent of the refcount as
 there is no need to include the refcount in the output?

There certainly is a need to consider the refcount. Else the memo
would not work.

 What other way (using pickle or not) can I convert a generic immutable
 Python object to a string to use as a key in external storage?

You will have to come up with your own serialization function. There
are MANY reasons why using a pickle cannot work. For example, in a
dictionary, the order of keys is not guaranteed, and might change even
though the dictionaries compare equal.

 Currently the documentation points out that the output may be different
 between pickle and cPickle which implies that the output will be
 consistent for a single module.

I doesn't imply this at all. The sentence says just what it says: don't
be surprised if you pickle the same object with pickle and cPickle,
and get different results.

 If pickle is not required to produce consistent output for the same
 input (and refcount isn't really part of the input in this case; it is 
 a side issue) than can this be documented?

It's certainly possible to document that, yes. Can you propose a
specific patch to the documentation?

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue5518
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue5518] cPickle produces inconsistent output

2009-03-19 Thread Martin v. Löwis

Martin v. Löwis mar...@v.loewis.de added the comment:

I'm not quite sure why you expect them to be the same. The inputs are
different, after all - in one case, you have a Unicode object with a
single reference to it (from the tuple), in the second case, you have a
Unicode object with many more references:

py sys.getrefcount(key[1])
2
py sys.getrefcount((1,u'foo')[1])
5

That makes a difference for cPickle.

--
nosy: +loewis
resolution:  - invalid
status: open - pending

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue5518
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com