Hacker News new | ask | show | jobs
by Animats 1711 days ago
Yes. I once discovered that CPickle was not thread-safe. The response was that much of the library didn't really work in multi-threaded programs.
1 comments

You mean programs where you put an object into pickle and some other threads modify it while pickle is processing it? Doesn't surprise me - the equivalent written in plain Python would be very thread unsafe as well.
No, I mean several threads doing completely separate CPickle streams with no shared data or variables at the Python level.
Has it since been fixed?
Probably not. CPickle is famously shunned by anyone who has to do serious, performance-critical serialization/deserialization.
I was curious, and an issue that fits the description was fixed in Py 3.7.x here: https://bugs.python.org/issue34572 but other threading bugs remain: https://bugs.python.org/issue38884
What’s the most performance critical alternative? Pickle is tied to the VM, so it’s not a generally good persistence option in a prod setup, but it can mighty convenient.
What do people use instead?
JSON, protocol buffers, thrift, etc. Saving python-native objects such as functions, class instances etc is usually not the right thing to do in production code.