I was wondering how to describe this great presentation, by Richard T. Saunders. Just found this sentence: This is one of those lectures that open your mind.
One of the most mysterious thing in Python is the pickle module. He is able to serialize almost any object in Python and, symmetrically, deserialize it. Its usage looks just like magic, because it is simple and intuitive. In this talk, after a brief introduction about the pickle, its alternatives and comparisons, Mr. Saunders explains in detail the inner pieces of the pickle module.
Many will say it is not necessary to know (or it’s a waste of time to study) how pickle works, we just need to know how to use it. I believe that having this kind of knowledge is an ace in the hole! One day, when you’re dealing with a real problem, your subconscious will nudge you and say: "You can solve this problem using the same logic used in the pickle module."
Richard T. Saunders uses Python in his 10 years working in Rincon Research Corporations and is also a professor of Software Engineering at the Arizona University. In his work he "reversed engineered" the pickle module and as a "consequence" of this, he created the PicklingTools library, an open source library to communicate Python with C++.
In this speech Mr. Saunders covers many points as:
- Origin of the pickle name;
- What is pickle, pickling and unpickling;
- What is serialization;
- Pickling and unpickling examples, used to save a game state;
- Pickle alternatives (Marshall, XML, JSON, and Google protocol buffers);
- Why use pickle (advantages and disadvantages);
- Comparisons between the pickle alternatives;
- Pickle versions (0, 1, 2 and 3) and a brief history of each;
- Comparisons between pickle versions;
- Machine code analysis (opcodes, value stack and the mark stack) used by pickle;
The slides from talk is available for download here in PDF.
At the end of this lecture I was surely tempted to write a "simplified" pickle module, just to be sure that I can.