-
-
Notifications
You must be signed in to change notification settings - Fork 30k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
cPickle.dumps change after for #37503
Comments
try this program: import cPickle
a=([{}])
print cPickle.dumps(a)
for x in a:
pass
cPickle.dumps(a) It prints: Why on earth it does dumps return different string? |
Logged In: YES Umm: >>> a=([{}])
>>> cPickle.dumps(a)
'(lp1\n(da.' you're only printing the first pickle... |
Logged In: YES I forgot to print the second dumps but the bug remains: |
Logged In: YES You're right, sorry. |
Logged In: YES OK, I think I know what's happening. Look at this: >>> a = {}
>>> cPickle.dumps(a)
'(dp1\n.'
>>> cPickle.dumps({})
'(d.' the only difference is in the number of references to the Why does this matter to you? |
Logged In: YES I would like to use hash(cPickle.dumps(a)) to have a unique |
Logged In: YES Well, that's asking for something you're not promised. It It seems using pickle in place of cPickle *may* work, fwiw. |
Logged In: YES Closed as Not-A-Bug. The internals of pickle strings aren't So a reliable hash code for a dict needs to be independent of |
Logged In: YES Someone else ran into the problem of unexpectedly varying http://sourceforge.net/tracker/?func=detail&atid=429622&aid=875331&group_id=41036 Maybe this behavior should be documented. |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: