cPickle, NetworkX: Why is inheritance faster than delegation?
<p>I am using NetworkX to process large graphs. I want to serialize/deserialize those graphs, and I can do that efficiently using cPickle. However, I noticed a performance penalty when I use delegation instead of inheritance, for example:</p>

<pre><code>class A:
   def __init__(self, **kwargs):
      self.graph = Digraph()

class A(DiGraph):
   def __init__(self, **kwargs):
      DiGraph.__init__(self, **kwargs)
</code></pre>

<p>Later at some point, I use cPickle.loads to retrieve the graph and load it into memory. I benchmarked the loading times and the delegation-style graph is loaded 2 times slower than the inheritance style. Performance is an issue for me, and I was wondering why does this happen..</p>
