title: copy.deepcopy raises TypeError on objects with self-defined __new__() method
body: <p>I want to implement a symbol type, which keeps track of the symbols we already have(saved in <code>_sym_table</code>), and return them if they exist, or create new ones otherwise. The code:</p>
  
  <pre><code># -*- coding: utf-8 -*-
  
  _sym_table = {}
  
  class Symbol(object):
      def __new__(cls, sym):
          if sym not in _sym_table:
              return super().__new__(cls)
          else:
              return _sym_table[sym]
  
      def __init__(self, sym):
          self.sym = sym
          _sym_table[sym] = self
  
      def __str__(self):
          return self.sym
  
      def __cmp__(self, other):
          return self is other
  
      def __hash__(self):
          return self.sym.__hash__()
  </code></pre>
  
  <p>But when I call <code>copy.deepcopy</code> on a list of such <code>Symbol</code> instances, exception is raised:</p>
  
  <pre><code>a = Symbol('a')
  b = Symbol('b')
  s = [a, b]
  t = copy.deepcopy(s)
  </code></pre>
  
  <p>Error messages:</p>
  
  <pre><code>Traceback (most recent call last):
    File "xxx.py", line 7, in &lt;module&gt;
      t = copy.deepcopy(s)
    File "/usr/lib/python3.2/copy.py", line 147, in deepcopy
      y = copier(x, memo)
    File "/usr/lib/python3.2/copy.py", line 209, in _deepcopy_list
      y.append(deepcopy(a, memo))
    File "/usr/lib/python3.2/copy.py", line 174, in deepcopy
      y = _reconstruct(x, rv, 1, memo)
    File "/usr/lib/python3.2/copy.py", line 285, in _reconstruct
      y = callable(*args)
    File "/usr/lib/python3.2/copyreg.py", line 88, in __newobj__
      return cls.__new__(cls, *args)
  TypeError: __new__() takes exactly 2 arguments (1 given)
  </code></pre>
  
  <p>So my questions are:</p>
  
  <ul>
  <li>How can I make a deep copy on these objects with self-defined <code>__new__</code> methods? </li>
  <li>And any suggestions about when and how to use <code>copy.deepcopy</code>? </li>
  </ul>
  
  <p>Thanks a lot!</p>