[IronPython] Dict convertion question

Bruce Christensen t-bruch at microsoft.com
Thu Jul 20 08:10:56 PDT 2006


Thanks for the feedback. In CPython, there are actually two
implementations of pickle: one written in Python (pickle) and one
written in C (cPickle). Only the Python version of pickle is available
in beta 9, but we're hoping to include an implementation of cPickle,
which should be quite a bit faster, in a future release of IronPython.

What is the nature of the dict that you're trying to save? How many
elements does it have, and what data types are those elements? Maybe
there's something we can do to improve pickle's performance for you.

--Bruce

-----Original Message-----
From: users-bounces at lists.ironpython.com
[mailto:users-bounces at lists.ironpython.com] On Behalf Of JoeSox
Sent: Wednesday, July 19, 2006 10:06 PM
To: Discussion of IronPython
Subject: Re: [IronPython] Dict convertion question

Perfect Bruce thanks for the suggestion. Thanks exactly what I was
looking for.  However, it took around six minutes to create a file
using pickle, as opposed to one second when I used File.WriteAllText.
I understand pickle may be compressing but the space savings is not a
significant enough benefit.  Here's my code examples below and the
file sizes(both used the same Dict):

Dict myDict = new Dict();
engine.ExecuteToConsole("fw={}");
engine.ExecuteToConsole("fw=c.fw_edges");//c.fw_edges is the large
dictionary
myDict = (Dict)engine.Globals["fw"];
File.WriteAllText(Application.StartupPath + "\\mydict.txt",
myDict.ToCodeString());
(This results in a file size of 1,540,096 bytes which was created in
about a second.)

======
engine.Globals["myfile"] = Application.StartupPath + "\\fw_edges.txt";
engine.Import("pickle");
engine.ExecuteToConsole("output =open(myfile, 'wb')");
engine.ExecuteToConsole("pickle.dump(c.fw_edges,output, protocol=2)");
engine.ExecuteToConsole("output.close()");
(This results in a file size of 1,052,672 bytes which was created in
about six minutes or more.)

I would like the speed of File.WriteAllText, the compression is not
really an issue for me.
-- 
Later, Joe

On 7/19/06, Bruce Christensen <t-bruch at microsoft.com> wrote:
> Since we just added support for this, please let us know if you run
into
> any problems.
> --Bruce
_______________________________________________
users mailing list
users at lists.ironpython.com
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com


More information about the users mailing list