Le 17/08/2014 19:41, Raymond Hettinger a écrit :
The APIs have been around since 2.6 and AFAICT there have been zero demonstrated need for a special case for a single byte. We already have a perfectly good spelling: NUL = bytes([0])
That is actually a very cumbersome spelling. Why should I first create a one-element list in order to create a one-byte bytes object?
The Zen tells us we really don't need a second way to do it (actually a third since you can also write b'\x00') and it suggests that this special case isn't special enough.
b'\x00' is obviously the right way to do it in this case, but we're concerned about the non-constant case.
The reason to instantiate bytes from non-constant integer comes from the unfortunate indexing and iteration behaviour of bytes objects.
Regards Antoine. _______________________________________________ Python-Dev mailing list Python-Dev@python.org https://mail.python.org/mailman/listinfo/python-dev Unsubscribe: https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com