The marshal Module

The marshal module can also be used for serialization

  • To serialize
     import marshal
     marshal.dump(obj,file)        # Write obj to file 
  • To unserialize
     obj = marshal.load(file)

Notes

  • marshal is similiar to pickle, but is intended only for simple objects
  • Can't handle recursion or class instances.
  • On the plus side, it's pretty fast if you just want to save simple objects to a file.
  • Data is stored in a binary architecture independent format
<<< O'Reilly OSCON 2000, Advanced Python Programming, Slide 47
July 17, 2000, beazley@cs.uchicago.edu
>>>