title: Avoid __new__ to be called every time
body: <p>I understood that classes are instances of metaclasses and that <code>__new__</code> is running  before <code>__init__</code>, because, you must create an instance before initializing it.</p>
  
  <p>Imagine now the following :</p>
  
  <pre><code>import time
  class ConfigurationsMeta(type):
      def __new__(cls, name, bases, attr):
          # Potentially a long task here (eg: Getting value from a web service)
          time.sleep(2)
  
          # Which class inherit from me (debug)
          print(f'Class {name}')
  
          config = super().__new__(cls, name, bases, attr)
  
          #Set a variable to be propagated (Variable coming from web service)
          setattr(config, "URL", "https://stackoverflow.com/")
  
          return config
  
  class Foo(metaclass=ConfigurationsMeta):
      def __init__(self):
          print(f'{__class__.__name__} : {self.URL}')
  
  class Bar(Foo):
      def __init__(self):
          print(f'{__class__.__name__} : {self.URL}')
  
  class Baz(Bar):
      def __init__(self):
          print(f'{__class__.__name__} : {self.URL}')
  
  e = Foo()
  s = Bar()
  c = Baz()
  </code></pre>
  
  <ol>
  <li><p>Nice because URL is well propagated as I do have </p>
  
  <pre><code>Foo : https://stackoverflow.com/
  Bar : https://stackoverflow.com/
  Baz : https://stackoverflow.com/
  </code></pre></li>
  <li><p>I do have now something I don't understand very well : </p>
  
  <p><code>Class Foo</code> is written after 2 sec</p>
  
  <p><code>Class Bar</code> is written after another 2 sec</p>
  
  <p><code>Class Baz</code> is written finally after another 2 sec</p></li>
  </ol>
  
  <p>So metaclass is executed three times. 
  This must explain that as <code>__new__</code> is responsible for creating classes, it must be run every time, so three times. </p>
  
  <p>Am I right?</p>
  
  <p>How can I avoid it and make it run only once? </p>