pickle.load failing with ValueError: insecure string pickle

carroll at tjc.com carroll at tjc.com
Tue Feb 11 15:40:23 EST 2003


On Tue, 11 Feb 2003 12:49:19 -0500, Tim Peters <tim.one at comcast.net>
wrote:

>Bingo -- that didn't close the file, it merely retrieved the close method of
>the file and then ignored it.  You want
>
>pickleout.close()

Doh!   That's the second time I've burned myself on that; first time
was using "sort" instead of "sort()".

Thanks.  It works fine now.

>  Note that pickle's "binary mode" is more
>efficient than its default "text mode".  A special caution for you, since
>you said later you're running on Windows:  when you use the pickle binary
>mode, you must also open your pickle files (for both reading and writing) in
>binary mode ("rb" and "wb").

Thanks for that hint.  I was planning to use binary, but I thought I'd
start "just like the book" before tweaking it.  I don't know if I
would have caught the binary modes.

Using the binary pickle, I'm loading a 1.4 meg file in about 4
seconds, instead of reading a 25 meg file in about 15 seconds.





More information about the Python-list mailing list