File Naming: .p vs .pkl vs .pickle

When reading and writing pickle files, I noticed that some fragments use .pothers .pkland some full ones .pickle. Is there any pythonic way to do this?

My real opinion is that there is not a single correct answer, and that any of them will be sufficient. In fact, writing a file name awesome.pklor awesome.saucewill not matter at startup pickle.load(open(filename, "rb")). This means that the file extension is just a convention that does not actually affect the underlying data. Is it correct?

Bonus: What if I saved the PNG image as myimage.jpg? What chaos will this create?

+4
source share
1 answer

Expansion makes no difference because the " Pickle Protocol " is launched every time.

That is, when pickle.dumps or pickle.loads are run, objects are serialized / non-serialized according to the pickle protocol.

(Sort protocol is a serialization format )

python ( ). , → - , /, , , , , Java.

, , , pickler .

JSON - , pickle - python, :/

,

+2

Source: https://habr.com/ru/post/1669531/


All Articles