Search code examples
rubyalgorithmmarshallingunmarshallingminimization

Faster/more efficient alternatives to Ruby's Marshal?


I'm looking for a drop-in replacement of Ruby's Marshal capability, which hopefully has one or more of the following advantages over Marshal:

  • faster serialization/deserialization
  • more concise (or simply smaller) object-graph

Thanks!!


Solution

  • Msgpack is focused on all of that. To replace Marshal:

    require 'msgpack'
    
    module Marshal
      module_function
      def dump(x)
        x.to_msgpack
      end
      def load(x)
        MessagePack.unpack x
      end
      alias restore load
    end
    

    http://msgpack.sourceforge.net/