[IronPython] Dict convertion question

JoeSox joesox at gmail.com
Thu Jul 20 07:05:32 CEST 2006

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=c.fw_edges");//c.fw_edges is the large dictionary
myDict = (Dict)engine.Globals["fw"];
File.WriteAllText(Application.StartupPath + "\\mydict.txt",
(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.ExecuteToConsole("output =open(myfile, 'wb')");
engine.ExecuteToConsole("pickle.dump(c.fw_edges,output, protocol=2)");
(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

More information about the Ironpython-users mailing list