title: How can I quickly set a Python bytearray to 0
body: <p>When a Python bytearray is created (with an integer passed to it) it creates a bytearray of that many bytes, and sets them all to zero.</p>
  
  <p>I want to clear the bytearray, and it could be quite large, iterating over it and setting the contents to zero that way is pretty poor.</p>
  
  <p>Is there a better way? </p>
  
  <p>(memoryviews and bytearrays are poorly documented IMO)</p>
  
  <p>Best resources so far (but none of them answer my question)</p>
  
  <p><a href="http://docs.python.org/dev/library/stdtypes.html#bytes-methods" rel="nofollow">http://docs.python.org/dev/library/stdtypes.html#bytes-methods</a></p>
  
  <p><a href="http://docs.python.org/dev/library/functions.html#bytearray" rel="nofollow">http://docs.python.org/dev/library/functions.html#bytearray</a></p>