title: Does python need barrier command to do singleton code?
body: <p>While write a singleton code in C/C++ you need barrier as bellow. Does python have(or need ) this command? why?</p>
  <pre><code>volatile T* pInst = 0;
  
  if (pInst == NULL)
  {
    lock()
    if (pInst == NULL)
    {
      T* temp = new T;
      barrier;  
      // the barrier prevent the cpu change the execute order 
      // first allocate memory (at this time pInst is not null) then generate T
      pInst = temp; 
    }
    unlock;
  }
  </code></pre>