[Python-3000] Immutable bytes -- looking for volunteer (original) (raw)

Victor Stinner victor.stinner at haypocalc.com
Wed Sep 19 12:12:10 CEST 2007


Hi,

On Tuesday 18 September 2007 04🔞01 Guido van Rossum wrote:

I'm considering the following option: bytes would always be immutable, (...) make b[0] return a bytes array of length 1 instead of a small int

Great idea! That will help migration from Python 2.x to Python 3.0. Choosing between byte and character string is already a difficult choice. So choosing between mutable (current bytes type) and immutable string (current str type) is a more difficult choice.

And substring behaviour change (python 2.x => 3) was also strange for python programmers.

'xyz'[0] 'x' b"xyz"[0] 120

This result is not symmetric. I would prefer what Guido proposes:

'xyz'[0] 'x' b"xyz"[0] b'x'

And so be able to write such tests:

b"xyz"[:2] == b'xy' True b"xyz"[0:1] == b'x' True b"xyz"[0] == b'x' True

Victor Stinner http://hachoir.org/



More information about the Python-3000 mailing list