title: Python 3 alternatives for __getinitargs__
body: <p>Is there a short enough way to call the <code>__init__</code> constructor of a class during unpickling in Python 3? The usual way to do this was using <code>__getinitargs__</code> like so</p>
  <pre><code>from __future__ import print_function
  import pickle
  
  class Car:
  
      def __init__(self, model, number):
          self.model = model
          self.number = number
          print(&quot;constructed with&quot;, model, number)
          # many other things to do
         
      def __getstate__(self):
          # intentionally returns None
          pass
  
      def __setstate__(self, state):
          pass
  
      def __getinitargs__(self):
          # save some information when pickling
          # (will be passed to the constructor upon unpickling)
          return self.model, self.number
  
  c = Car(&quot;toyota&quot;, 1234)
  d = pickle.loads(pickle.dumps(c))
  print(&quot;reconstructed with&quot;, d.model, d.number)
  </code></pre>
  <p>However, the <code>__getinitargs__</code> will be ignored in new style classes and in Python 3+, all classes can only be new style classes. There is the <code>__getnewargs__</code> but it will pass the arguments only to the <code>__new__</code> class method which is not the same. A python 2 call of the above illustrative example will result in</p>
  <pre><code>&gt;&gt; constructed with toyota 1234
  &gt;&gt; constructed with toyota 1234
  &gt;&gt; reconstructed with toyota 1234
  </code></pre>
  <p>while a python 3 call will error out</p>
  <pre><code>&gt;&gt; constructed with toyota 1234
  Traceback (most recent call last):
    File &quot;test.py&quot;, line 26, in &lt;module&gt;
      print(&quot;reconstructed with&quot;, d.model, d.number)
  AttributeError: 'Car' object has no attribute 'model'
  </code></pre>
  <p>and ignore the <code>__getinitargs__</code> method.</p>
  <p>I don't think Python 3 will easily regress in that regard so hopefully I am missing something obvious.</p>
  <p><strong>EDIT</strong>: Replacing <code>__getinitargs__</code> with <code>__getnewargs__</code> does not solve the issue.</p>