Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #41116

Re: Store a variable permanently

Date 2013-03-12 12:54 +0100
From Jean-Michel Pichavant <jeanmichel@sequans.com>
Subject Re: Store a variable permanently
Newsgroups comp.lang.python
Message-ID <mailman.3223.1363089272.2939.python-list@python.org> (permalink)

Show all headers | View raw


----- Original Message -----
> On Mon, 11 Mar 2013 11:19:49 +0100, Jean-Michel Pichavant wrote:
> 
> [...]
> > While your point about security is fair, the others aren't. Pickle
> > uses
> > by default an ascii representation of the data, it's readable and
> > writeable.
> > 
> > import pickle
> > a = 758
> > pickle.dump(a, open('test.pickle', 'w'))
> > !cat test.pickle
> > I758
> > .
> 
> 
> What is that? It's not Python code, !cat test.pickle gives a syntax
> error.

It's a IPython shell session, !cat test.pickle writes the content of that file to stdout. But I have the feeling you already know that ;)

[snip] 
> Pickle is a big module, over 1400 lines, capable of serialising
> almost
> anything. It's a big, powerful hammer for cracking armour-plated
> coconuts. But a single int is pretty much a peanut. Compare pickle's
> 1400
> lines with the dozen or so lines I provided. That is all that I meant
> by
> "overkill".

I would be surprised if the 1400 lines were used to dump an integer. Anyway who cares about the size of the module, a lot of people import sys and os while using only a very subset of it.

And to reuse your analogy, there's nothing wrong cracking a peanut with a hammer as long as you have it in your hands and that it takes absolutely no effort, compared to building your own small peanut cracker. Trying to crack the peanut by landing an airplane on it, that would work *and* be "overkill".

Now about analogies:
http://www.linguistrix.com/blog/?p=456

Cheers,

JM







-- IMPORTANT NOTICE: 

The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for any purpose, or store or copy the information in any medium. Thank you.

Back to comp.lang.python | Previous | NextNext in thread | Find similar | Unroll thread


Thread

Re: Store a variable permanently Jean-Michel Pichavant <jeanmichel@sequans.com> - 2013-03-12 12:54 +0100
  Re: Store a variable permanently Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-03-13 17:37 +0000
    Re: Store a variable permanently Chris Angelico <rosuav@gmail.com> - 2013-03-14 11:22 +1100

csiph-web