Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #35610
| Path | csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <python-python-list@m.gmane.org> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.001 |
| X-Spam-Evidence | '*H*': 1.00; '*S*': 0.00; 'versions,': 0.05; 'objects,': 0.07; 'python': 0.09; 'bytes,': 0.09; "object's": 0.09; 'of)': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'subject:module': 0.09; '2.7': 0.13; '(the': 0.15; 'file,': 0.15; '2.7?': 0.16; 'program?': 0.16; 'received:80.91.229.3': 0.16; 'received:dip.t-dialin.net': 0.16; 'received:plane.gmane.org': 0.16; 'received:t-dialin.net': 0.16; 'later': 0.16; 'string': 0.17; 'wrote:': 0.17; 'module,': 0.17; 'string,': 0.17; 'load': 0.19; 'module': 0.19; 'skip:p 30': 0.20; 'translate': 0.20; 'written': 0.20; 'object.': 0.22; 'somebody': 0.23; 'project,': 0.24; 'header:User-Agent:1': 0.26; 'creating': 0.26; 'header:X -Complaints-To:1': 0.28; 'actual': 0.28; 'embed': 0.29; 'parameters.': 0.29; 'pickle': 0.29; 'piece': 0.29; 'protocols': 0.29; 'yields': 0.29; 'objects': 0.29; 'source': 0.29; 'class': 0.29; "i'm": 0.29; 'maybe': 0.29; 'classes': 0.30; 'knows': 0.30; 'code': 0.31; 'file': 0.32; 'anybody': 0.32; "aren't": 0.33; 'platforms.': 0.33; 'problem': 0.33; 'to:addr:python-list': 0.33; 'version': 0.34; "can't": 0.34; 'project': 0.34; 'so,': 0.35; 'there': 0.35; 'received:org': 0.36; 'but': 0.36; 'loaded': 0.36; 'method': 0.36; "i'll": 0.36; 'possible': 0.37; 'does': 0.37; 'subject:: ': 0.38; 'nothing': 0.38; 'instead': 0.39; 'to:addr:python.org': 0.39; 'short': 0.39; 'application': 0.40; 'header:Received:5': 0.40; 'save': 0.61; 'containing': 0.61; 'solve': 0.62; 'provide': 0.62; 'between': 0.63; 'series': 0.63; 'different': 0.63; 'information': 0.63; 'results': 0.65; '2.7.': 0.84; 'web!': 0.91 |
| X-Injected-Via-Gmane | http://gmane.org/ |
| To | python-list@python.org |
| From | Peter Otten <__peter__@web.de> |
| Subject | Re: pickle module doens't work |
| Date | Thu, 27 Dec 2012 12:29:19 +0100 |
| Organization | None |
| References | <ee10f0f7-7713-4879-82a1-ec5804767af6@googlegroups.com> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset="ISO-8859-1" |
| Content-Transfer-Encoding | 7Bit |
| X-Gmane-NNTP-Posting-Host | p5084a838.dip.t-dialin.net |
| User-Agent | KNode/4.7.3 |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.15 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list/> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.1339.1356607732.29569.python-list@python.org> (permalink) |
| Lines | 37 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1356607732 news.xs4all.nl 6934 [2001:888:2000:d::a6]:47950 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:35610 |
Show key headers only | View raw
Omer Korat wrote:
> I'm working on a project in Python 2.7. I have a few large objects, and I
> want to save them for later use, so that it will be possible to load them
> whole from a file, instead of creating them every time anew. It is
> critical that they be transportable between platforms. Problem is, when I
> use the 2.7 pickle module, all I get is a file containing a string
> representing the commands used to create the object. But there's nothing I
> can do with this string, because it only contains information about the
> object's module, class and parameters. And that way, they aren't
> transportable. In python 3.3 this problem is solved, and the pickle.dump
> generates a series of bytes, which can be loaded in any other module
> independently of anything. But in my project, I need NLTK 2.0, which is
> written in python 2.7...
>
> Anybody has suggestions? Maybe there is a way to use pickle so that it
> yields the results I need? Or is there any other module that does pickle's
> job? Or perhaps there is a way to mechanically translate between python
> versions, so I'll be able to use pickle from 3.3 inside an application
> written in 2.7? Or perhaps somebody knows of a way to embed a piece of 3.3
> code inside a 2.7 program?
>
> It can't be I'm the only one who wants to save python objects for later
> use! There must be a standard method to do this, but I couldn't find any
> on the web! If someone can solve this for me I'll be so grateful.
Pickling works the same way in Python 2 and Python 3. For classes only the
names are dumped, so you need (the same version of) NLTK on the source and
the destination platform.
If you can provide a short demo of what works in Python 3 but fails in
Python 2 we may be able to find the actual problem or misunderstanding.
Maybe it is just that different protocols are used by default? I so, try
with open(filename, "wb") as f:
pickle.dump(f, your_data, protocol=pickle.HIGHEST_PROTOCOL)
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
pickle module doens't work Omer Korat <animus.partum.universum@gmail.com> - 2012-12-27 02:46 -0800
Re: pickle module doens't work Peter Otten <__peter__@web.de> - 2012-12-27 12:29 +0100
Re: pickle module doens't work Omer Korat <animus.partum.universum@gmail.com> - 2012-12-27 04:05 -0800
Re: pickle module doens't work Dave Angel <d@davea.name> - 2012-12-27 07:34 -0500
Re: pickle module doens't work Omer Korat <animus.partum.universum@gmail.com> - 2012-12-27 05:16 -0800
Re: pickle module doens't work Chris Angelico <rosuav@gmail.com> - 2012-12-28 00:20 +1100
Re: pickle module doens't work Omer Korat <animus.partum.universum@gmail.com> - 2012-12-27 05:16 -0800
Re: pickle module doens't work Tim Roberts <timr@probo.com> - 2012-12-28 21:41 -0800
Re: pickle module doens't work Omer Korat <animus.partum.universum@gmail.com> - 2013-01-01 06:33 -0800
Re: pickle module doens't work Tim Roberts <timr@probo.com> - 2013-01-01 11:14 -0800
Re: pickle module doens't work Omer Korat <animus.partum.universum@gmail.com> - 2013-01-02 06:08 -0800
Re: pickle module doens't work Terry Reedy <tjreedy@udel.edu> - 2012-12-27 16:19 -0500
Re: pickle module doens't work Omer Korat <animus.partum.universum@gmail.com> - 2012-12-27 04:05 -0800
csiph-web