What is pickling in python

Understanding pickling in Python

Pickling is a mini language that can be used to convert the relevant state from a python object to a string, which string uniquely represents the object. Then pickling (un) can be used to convert the character string to a living object by "reconstructing" the object from the stored state that constitutes the character string.

Here you can see that pickle does not save the source code for the class, it saves a reference to the class definition. Basically you can almost read the selected string ... it says (roughly translated) "Call the reconstructor of copy_reg, with the arguments being the class defined by, and then do other things". The other stuff is the saved state of the instance. If you look closer, you can extract that "string x" is set to "the integer 2" (roughly:). This is actually a truncated part of the selected string for a dictionary entry. That is, so. If you look at the source code for, you will get a unique translation for each object type and each operation of python on the selected bytecode.

Also note that there are different variants of the address language. The default setting is Protocol 0, which is easier to read. There is also protocol 2 (and 1,3 and 4, depending on the version of python you're using)).

Again, it's still a dialect of the collateral language, and you can see the string of log 0 is "get a list including I1, I2, I3" while log 2 is harder to read but says the same thing. The first bit indicates that it is protocol 2. Then you have, that says it is a list. Then you can see the whole numbers 1,2,3 in it again. Check the source code for pickle again to see the exact mapping for the mordant language.

Use load / loads to reverse the pickling into a string.