title: What does __flags__ in python type used for
body: <p>I have been read pickle source code recently.</p>
  
  <p>The following code in <code>copy_reg</code> make me confused:</p>
  
  <pre><code>_HEAPTYPE = 1&lt;&lt;9
  
  def _reduce_ex(self, proto):
      assert proto &lt; 2
      for base in self.__class__.__mro__:
          if hasattr(base, '__flags__') and not base.__flags__ &amp; _HEAPTYPE:
              break
      else:
          base = object # not really reachable
      if base is object:
          state = None
  </code></pre>
  
  <p>So what does <code>__flags__</code> using for?</p>
  
  <p>I found it is defined in <code>type</code> object:</p>
  
  <pre><code>type.__flags__ = 2148423147
  </code></pre>
  
  <p>I was tried to search it in the official doc, but nothing was found.</p>
  
  <p>But interesting thing is that <code>__class__.__flags__ &amp; _HEAPTYPE</code> is always <code>0</code> when the <code>__class__</code> is python internal type. And the result will be <code>1</code> when <code>__class__</code> is a subclass of python internal type.</p>
  
  <p>Can anyone help me to solve this puzzle?</p>