Python Pickle Module for saving objects (serialization)

preview_player
Показать описание
This Python programming tutorial covers how to pickle objects in Python.

The pickle module implements binary protocols for serializing and de-serializing a Python object structure. “Pickling” is the process whereby a Python object hierarchy is converted into a byte stream, and “unpickling” is the inverse operation, whereby a byte stream (from a binary file or bytes-like object) is converted back into an object hierarchy. Pickling (and unpickling) is alternatively known as “serialization”, “marshalling,” [1] or “flattening”; however, to avoid confusion, the terms used here are “pickling” and “unpickling”.

Рекомендации по теме
Комментарии
Автор

"it's useful just for anything that requires a lot of processing and ends with an object" wonderful, thanks for the clear explanation!

kbprojekty
Автор

Dude, every time I need an answer you are always popping up as one of the subscriptions to provide one. You are smart as hell! Take a bow my good Clap)

jamelstringer
Автор

You know when you try and find a video about something and you never find one. Then 2 years later you find one which is perfect. This is one of those videos. Very helpful and clear. Cheers!

sammypoulsom
Автор

Thank you, I hadn't heard the word 'pickle' enough in my life and now I have. I'm ready to die now...

sizlax
Автор

Good video, thanks Jesse.

I just have two points to add for beginners.

1. 'with' is recommended by Python 2.7 docs to use for handling files.
The first block of code in the video can be re-written as:

with open("dict.pickle", "wb") as file:
pickle.dump(example_dict, file)

And just that. No need to close the file, it will close automatically as soon as that 'with' section is done. There's also some functionality related benefits to using 'with' over manually stating to close the file. E.g. if you have a return in that 'with' block then the file will close as soon as it returns. The second block can be re-written in the same way.

2. Look into cPickle. Runs much faster and is the exact same as pickle bar some areas.

andrewpeters
Автор

Thank you very much for your videos! I am working on a term project for an introductory python class and am required to use modules we did not cover in class. I've been sifting through tutorials all over the web, and a lot of the written definitions are extremely complicated for a novice like me to understand, and not thorough in their explanations. I found your videos to be extraordinarily helpful and clear. Thank you!

pearlwhite
Автор

OMG, you gave me the answer I needed. I am just trying to save a freaking dictionary to a file, and reload it again when I start my program. Everywhere I look, SQL Lite, SQL, databases!!!! I am NOT ready for all that yet, and wanted something simple.

You showed me pickle. THANK YOU!!

majicMix
Автор

God bless you my graduation project based on ML and u make it easy for me thank you dude

mostafael-sayed
Автор

I used this to save calibration coordinates on my cartesian robot, and it worked. Thanks a bunch.

pekhotinyets
Автор

Thank you Mr. Snowden for your python tutorial. I appreciate you helpin' us out from Russia.

vincentruan
Автор

Mr Sendex, you are so clutch, just always managing to pull through at the right time

thembekilethembekile
Автор

Sentdex always helping me when i need help the most. Thank you Sentdex

mbonuchinedu
Автор

Thanks for making this video and sharing the info, it was really helpful and clear to really understand the concept and the utility of pickle, also, great that you mentioned the risks of using it.

robertue
Автор

very helpfull, Im on a masters machine learning project, we need to serialize the data of a neural network model (time stamps) on the master Nvidia TX2 and send them through a socket to the corresponding slaves, your videos inspired me a lot both on sockt and pickling, thanks

machinelearning
Автор

Great video! You make these concepts crystal clear, and I appreciate it very much!

TheHvUXIV
Автор

Thank you so much! Finally got it working!

expiredlamb
Автор

very much interesting to learn python with your videos
Iam Final year btech in NIT TRICHY INDIA
Iam doing a project with python for sentiment analysis of BIG DATA and your videos are very much helpful !!! Thanks a lot!!!

RahulRaj-tgkr
Автор

great video, great energy, great pickle






pickle rick would be proud

anuragkadam
Автор

Thanks for this one, good as always.
Keep the good work going. :)

yankooz
Автор

I was searching for cucumber and gherkin. I found pickle! lol.

albertkaderdjehaf
visit shbcf.ru