bytes() and bytearray() functions bytes is an immutable version of bytearray – it has the same non-mutating methods and the same indexing and slicing behavior. bytearray() function : Return a new array of bytes. The bytearray type is a mutable sequence of integers in the range 0 <= x < 256.