Skip to main content

Difference between bytes and bytearray in Python


  • It returns the "bytes" Object. 
  • It is immutable. (cannot be modified once declared).
  • It is the sequence of a small integer whose range is from 0<=x<256.
bytes([source [, encoding [, errors]]])


  • This method returns the bytearray object (i.e. array of given bytes).
  • It is a mutable(can be modified) sequence of bytes.
  • It is the sequence of integers in the range 0 <= x < 256.
bytearray([source[,encoding [,errors]]])
Submitted by devanshi.srivastava on September 3, 2021

Devanshi, is working as a Data Scientist with iVagus. She has expertise in Python, NumPy, Pandas and other data science technologies.


At ProgramsBuzz, you can learn, share and grow with millions of techie around the world from different domain like Data Science, Software Development, QA and Digital Marketing. You can ask doubt and get the answer for your queries from our experts.