Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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!!

like image 764
Joseph Weissman Avatar asked Jun 22 '10 18:06

Joseph Weissman


2 Answers

Unfortunately that doesn't work as a drop in replacement because Marshall will automatically handle complex types. Looks like msgpack will require additional functionality to be built that (like Marshal's internals) will iterate the Ruby structures that define the object in question.

like image 159
Asher Avatar answered Sep 28 '22 22:09

Asher


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/

like image 25
Adrian Avatar answered Sep 28 '22 21:09

Adrian