title: Python: bytearray vs array
body: <p>What is the difference between <code>array.array('B')</code> and <code>bytearray</code>?</p>
  
  <pre><code>from array import array
  
  a = array('B', 'abc')
  b = bytearray('abc')
  
  a[0] = 100
  b[0] = 'd'
  
  print a
  print b
  </code></pre>
  
  <p>Are there any memory or speed differences? What is the preferred use case of each one?</p>