What's the most efficient way to deep copy an object in Ruby?
I know that serializing an object is (to my knowledge) the only way to effectively deep-copy an object (as long as it isn't stateful like IO and whatnot), but is one way particularly more efficient than another? For example, since I'm using Rails, I could always use ActiveSupport::JSON , to_xml - and from what I can tell marshalling the object is one of the most accepted ways to do this. I'd expect that marshalling is probably the most efficient of these since it's a Ruby internal, but am I missing anything? Edit : note that its implementation is something I already have covered - I don't want