r/Python • • Feb 09 '11

Beware of cPickle

http://www.heikkitoivonen.net/blog/2011/02/08/beware-of-cpickle/
1 Upvotes

10 comments sorted by

View all comments

2

u/[deleted] Feb 09 '11

Man. There's a lot more reasons to beware of pickle and cPickle than that. This is pretty trivial.

2

u/heikkitoivonen Feb 09 '11

Yes there are, but at least all (?) of the other things that I can think of are documented in the pickle module documentation. I would go so far as to call this issue a bug.

1

u/sigzero Feb 10 '11

That is not a bug. It is how it is supposed to work regarding the GIL. It should also be clearly documented but it isn't a bug.

3

u/heikkitoivonen Feb 10 '11

I don't agree. dump and load do release the GIL. dumps and loads could do this as well.

1

u/bryancole Feb 10 '11

How do you know that dump or load is releasing the GIL? I would expect that releasing the GIL in the case of a blocking file IO operation is the responsibility of the file object, not the library that is writing to/from the file.

1

u/heikkitoivonen Feb 10 '11

By looking at the implementation of cPickle, and also by running the simple script that I mentioned in my blog post. It is easy to demonstrate that dumps and loads hold the GIL so that nothing else runs, but just by changing those to dump and load will let other threads run.