title: About Deep Copy and Serialization
body: <p>I have read a lot about deep copying and serialization in Java <code>List</code>, <code>Map</code>, etc, but I did not find good answers to a some questions. I care for time and performance, so I am looking for a compromise. I list my questions below so that you can address the ones you have answers to.</p>
  
  <ol>
  <li><p>What is better in terms of performance, deepcopy by looping over a <code>list</code> or using serialization? I have read a post (sorry I lost the link) that says looping is 4 times better than java serialization. Does this mean that using a 3rd party like Kryo can be better than looping?</p></li>
  <li><p>I am not sure how serialization works in different <a href="http://code.google.com/p/thrift-protobuf-compare/wiki/Benchmarking" rel="nofollow">3rd party libraries</a>, but what happens if I have many subclass levels, would serialization be better than looping?</p></li>
  <li><p>Is there any library in Java that copies raw memory? For instance, a library that uses <code>memcopy()</code>-like functions in <code>C</code>. That would be much faster since there is no need to care about classes logic (of course it needs some handling for non-contiguous memory data). I am aware that Java is object oriented :), but this wont violate rules I think.</p></li>
  <li><p>If I want to implement <code>deepCopy(List&lt;?&gt;)</code> and <code>deepCopy(Map&lt;?,?&gt;)</code> in Java, can I put them in a <code>MyTools</code> class that I have; or there is some neater way to do it in Java?</p></li>
  </ol>