From the course: Effective Serialization with Python

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Marshal and pickle serialization

Marshal and pickle serialization - Python Tutorial

From the course: Effective Serialization with Python

Start my 1-month free trial

Marshal and pickle serialization

- Pickle is a Python specific format. The nice thing about working with pickle is that you don't need to think about how to serialize specific types. Most of the types that pickle can serialize are ones It doesn't make sense to serialize anyway. For example, open files, socket, et cetera. Most of the other types pickle cant serialize, are live code such as lambda expressions, generator objects, et cetera. Let's see an example. We define our own class of a dance move. It has a time, a limb, and what to do. And then we define some moves, we define move one, move two, move three and move four. The pickle API has two sets of function. One is dump and load and the other is dump s and load s. The difference is that the ones with the s at the end return a bytes objects. Where the ones without the s, write and read the files and return none Let's play with pickle a bit. I'm using ipython shell, so iPython and ipython…

Contents