[Python-Dev] Why does read() return bytes instead of bytearray?
solipsis at pitrou.net
Thu Apr 16 01:16:29 CEST 2009
Lisandro Dalcin <dalcinl <at> gmail.com> writes:
> However, your original question is still valid ... Why a binary read()
> returns an immutable type?
Because bytes is the standard type for holding binary data. Bytearray should
only be used when there's a real, measured performance advantage doing so
(which, IMHO, is rarer than you think). An immutable type makes daily
programming much less error-prone.
More information about the Python-Dev