Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #92366
| References | <ml7a2p$hp$1@ger.gmane.org> |
|---|---|
| From | Zachary Ware <zachary.ware+pylist@gmail.com> |
| Date | 2015-06-09 13:38 -0500 |
| Subject | Re: enhancement request: make py3 read/write py2 pickle format |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.319.1433876675.13271.python-list@python.org> (permalink) |
On Tue, Jun 9, 2015 at 1:08 PM, Neal Becker <ndbecker2@gmail.com> wrote:
> One of the most annoying problems with py2/3 interoperability is that the
> pickle formats are not compatible. There must be many who, like myself,
> often use pickle format for data storage.
>
> It certainly would be a big help if py3 could read/write py2 pickle format.
> You know, backward compatibility?
Uhh...
$ python
Python 2.7.6 (default, Sep 9 2014, 15:04:36)
[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.39)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import pickle
>>> with open('test.pkl', 'wb') as f:
... pickle.dump({'test': [1, 2, {3}]}, f)
...
>>> with open('test.pkl', 'rb') as f:
... pickle.load(f)
...
{'test': [1, 2, set([3])]}
>>> ^D
$ python3
Python 3.4.3 (v3.4.3:9b73f1c3e601, Feb 23 2015, 02:52:03)
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import pickle
>>> with open('test.pkl', 'rb') as f:
... pickle.load(f)
...
{'test': [1, 2, {3}]}
>>> with open('test2.pkl', 'wb') as f:
... pickle.dump(['test', {2: {3.4}}], f, protocol=2)
...
>>> with open('test2.pkl', 'rb') as f:
... pickle.load(f)
...
['test', {2: {3.4}}]
>>> ^D
✔ ~
13:35 $ python
Python 2.7.6 (default, Sep 9 2014, 15:04:36)
[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.39)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import pickle
>>> with open('test2.pkl', 'rb') as f:
... pickle.load(f)
...
[u'test', {2: set([3.4])}]
>>>
--
Zach
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: enhancement request: make py3 read/write py2 pickle format Zachary Ware <zachary.ware+pylist@gmail.com> - 2015-06-09 13:38 -0500
csiph-web