title: Is modifying a class variable in python threadsafe?
body: <p>I was reading <a href="https://stackoverflow.com/questions/1071935/i-need-a-python-class-that-keep-tracks-of-how-many-times-it-is-instanciated">this question</a> (which you do not have to read because I will copy what is there... I just wanted to give show you my inspiration)...</p>
  
  <p>So, if I have a class that counts how many instances were created:</p>
  
  <pre><code>class Foo(object):
    instance_count = 0
    def __init__(self):
      Foo.instance_count += 1
  </code></pre>
  
  <p>My question is, if I create Foo objects in multiple threads, is instance_count going to be correct? Are class variables safe to modify from multiple threads?</p>