bytearray is the successor of Python 2.x's string type. It's basically the built-in byte array type. Unlike the original string type, it's mutable.
The array module, on the other hand, was created to create binary data structures to communicate with the outside world (for example, to read/write binary file formats).
Unlike bytearray, it supports all kinds of array elements. It's flexible.
So if you just need an array of bytes, bytearray should work fine. If you need flexible formats (say when the element type of the array needs to be determined at runtime), array.array is your friend.
Without looking at the code, my guess would be that bytearray is probably faster since it doesn't have to consider different element types. But it's possible that array('B') returns a bytearray.