Convert String to Dictionary question

Jeff Shannon jeff at ccvcorp.com
Thu Feb 14 19:20:33 EST 2002


MDK wrote:

> "John J. Lee" <jjl at pobox.com> wrote in message
> news:Pine.SOL.4.30.0202142127220.24038-100000 at mimosa.csv.warwick.ac.uk...
> > On Thu, 14 Feb 2002, MDK wrote:
> >
> > > I saved my dictionary {'hello1': [1, 0, 0]} to a file.
> > >
> > > When I do a readline the I get back a string.
> > >
> > > How do I convert this string to a dictionary?
> >
> > You probably don't want to.  Read the documentation for the pickle module.
> >
>
> Pickling seems too slow.

Are you using Pickle or cPickle?  They provide the same functionality, but
cPickle is implemented in C and is thus notably faster.  Pickle is kept around
because it's possible to subclass from it, whereas it's not possible to subclass
C code (though for most purposes, subclassing a pickler is unnecessary).

I suppose this may change soon--as of 2.2, types should be subclassable, so
there shouldn't be any further need to maintain the slower all-Python version.

Jeff Shannon
Technician/Programmer
Credit International





More information about the Python-list mailing list