title: Real world example of overriding __new__ method in Python
body: <p>I'm familiar with the theory about <code>__new__</code> vs <code>__init__</code>. The former one defines how an instance of a class is created (new object inside the memory), whereas the latter one initializes it (assigns initial state attributes - fields). There is a couple of articles in the web about this, such as <a href="https://mail.python.org/pipermail/tutor/2008-April/061426.html" rel="nofollow">this one</a>:</p>
  
  <blockquote>
    <p>Use <code>__new__</code> when you need to control the creation of a new instance.
    Use <code>__init__</code> when you need to control initialization of a new
    instance.</p>
  </blockquote>
  
  <p>As I said, I do understand the difference, yet, I can't imagine a real world example of situation when I need to use <code>__new__</code> instead of <code>__init__</code>. If I can customize something during object creation, I can move it to object initialization - as long as it's the same object. The mentioned link says:</p>
  
  <blockquote>
    <p>In general, you shouldn't need to override <code>__new__</code> unless you're
    subclassing an immutable type like str, int, unicode or tuple.</p>
  </blockquote>
  
  <p>And here comes my question - can someone give an example of situation, when overriding <code>__new__</code> is in fact the right solution that can't be done using <code>__init__</code> and why is that?</p>