This issue tracker has been migrated to GitHub ,
and is currently read-only.
For more information,
see the GitHub FAQs in the Python's Developer Guide.
Created on 2013年05月03日 19:40 by serhiy.storchaka, last changed 2022年04月11日 14:57 by admin. This issue is now closed.
| Files | ||||
|---|---|---|---|---|
| File name | Uploaded | Description | Edit | |
| OrderedDict_pickle_recursive.patch | serhiy.storchaka, 2013年05月03日 19:40 | |||
| test_yaml.py | rhettinger, 2014年11月02日 08:41 | Show the YAML breakage. | ||
| OrderedDict_pickle_PyYAML.patch | serhiy.storchaka, 2014年11月02日 14:56 | review | ||
| Messages (11) | |||
|---|---|---|---|
| msg188325 - (view) | Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) | Date: 2013年05月03日 19:40 | |
Here is a patch which allows pickling of recursive OrderedDicts. Actually it simplifies __reduce__() code. |
|||
| msg188344 - (view) | Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) | Date: 2013年05月04日 08:08 | |
In additional the patch decreases the size of the pickled data, speeds up pickling and unpickling. $ ./python -c "import collections, pickle; od = collections.OrderedDict((i, i) for i in range(100000)); print(len(pickle.dumps(od)))" Without patch: 1536827. With patch: 737578. $ ./python -m timeit -s "from pickle import dumps; import collections; od = collections.OrderedDict((i, i) for i in range(100000))" "dumps(od)" Without patch: 454 msec. With patch: 361 msec. $ ./python -m timeit -s "from pickle import dumps, loads; import collections; od = collections.OrderedDict((i, i) for i in range(100000)); x = dumps(od)" "loads(x)" Without patch: 1.41 sec. With patch: 1.15 sec. |
|||
| msg189662 - (view) | Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) | Date: 2013年05月20日 13:50 | |
Ping. |
|||
| msg189688 - (view) | Author: Alexandre Vassalotti (alexandre.vassalotti) * (Python committer) | Date: 2013年05月20日 20:22 | |
The patch looks good to me. So go ahead and submit it. :) |
|||
| msg189737 - (view) | Author: Roundup Robot (python-dev) (Python triager) | Date: 2013年05月21日 09:49 | |
New changeset 56f25569ba86 by Serhiy Storchaka in branch 'default': Issue #17900: Allowed pickling of recursive OrderedDicts. Decreased pickled http://hg.python.org/cpython/rev/56f25569ba86 |
|||
| msg230482 - (view) | Author: Raymond Hettinger (rhettinger) * (Python committer) | Date: 2014年11月02日 08:41 | |
This patch caused a regression by breaking designed-in support for pickling using PyYAML (note, there was a test for yaml support, but this patch defeated the test). As a result of the patch, ordering now gets lost during a dump/load roundtrip. This change should not have been committed without my review (I would have caught the problem instantly). |
|||
| msg230484 - (view) | Author: Antoine Pitrou (pitrou) * (Python committer) | Date: 2014年11月02日 12:09 | |
Can you explain what is broken independently of PyYAML? |
|||
| msg230487 - (view) | Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) | Date: 2014年11月02日 14:56 | |
Oh, sorry, I did not notice test_yaml_linkage. And in any case this test was broken (should be rv[1][0] instead of rv[1]). I don't like to revert these changes, and the reversion can break a code written for 3.4 which pickles recursive OrderedDicts. I suggest following solution. PyYAML calls __reduce_ex_(2) or __reduce__(). Therefore we can return to old behavior with protocol < 3 and left current behavior with protocol >= 3. Recursive OrderedDicts will be pickleable with default protocol and with highest protocol, and PyYAML will be happy. Does this patch look good to your? |
|||
| msg267778 - (view) | Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) | Date: 2016年06月08日 04:57 | |
I think it is too late to revert this change. Is it worth to add a workaround for PyYAML if it still hasn't fixed serialization of OrderedDicts? |
|||
| msg268314 - (view) | Author: Raymond Hettinger (rhettinger) * (Python committer) | Date: 2016年06月12日 02:36 | |
At this point, we can drop it. PyYAML will just have to deal with it. |
|||
| msg268347 - (view) | Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) | Date: 2016年06月12日 08:27 | |
Reported PyYAML issue: https://bitbucket.org/xi/pyyaml/issues/61/ordereddict-doesnt-round-trip. |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022年04月11日 14:57:45 | admin | set | github: 62100 |
| 2016年06月12日 08:27:22 | serhiy.storchaka | set | status: open -> closed resolution: fixed messages: + msg268347 stage: patch review -> resolved |
| 2016年06月12日 02:36:29 | rhettinger | set | assignee: rhettinger -> messages: + msg268314 |
| 2016年06月08日 04:57:02 | serhiy.storchaka | set | messages: + msg267778 |
| 2015年07月21日 07:45:15 | ethan.furman | set | nosy:
- ethan.furman |
| 2014年11月07日 17:17:33 | ethan.furman | set | nosy:
+ ethan.furman |
| 2014年11月02日 19:30:16 | rhettinger | set | assignee: serhiy.storchaka -> rhettinger |
| 2014年11月02日 14:56:24 | serhiy.storchaka | set | files:
+ OrderedDict_pickle_PyYAML.patch messages: + msg230487 stage: needs patch -> patch review |
| 2014年11月02日 12:09:01 | pitrou | set | messages: + msg230484 |
| 2014年11月02日 08:41:26 | rhettinger | set | status: closed -> open files: + test_yaml.py type: enhancement -> behavior versions: + Python 3.5 messages: + msg230482 resolution: fixed -> (no value) stage: resolved -> needs patch |
| 2013年05月21日 09:57:33 | serhiy.storchaka | set | status: open -> closed resolution: fixed stage: patch review -> resolved |
| 2013年05月21日 09:49:23 | python-dev | set | nosy:
+ python-dev messages: + msg189737 |
| 2013年05月20日 20:35:59 | serhiy.storchaka | set | assignee: serhiy.storchaka |
| 2013年05月20日 20:22:34 | alexandre.vassalotti | set | messages: + msg189688 |
| 2013年05月20日 13:50:55 | serhiy.storchaka | set | messages: + msg189662 |
| 2013年05月04日 08:08:18 | serhiy.storchaka | set | messages: + msg188344 |
| 2013年05月03日 19:40:16 | serhiy.storchaka | create | |