A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2014-August/135848.html below:

Minor API improvements for bytes & bytearray

[Python-Dev] PEP 467: Minor API improvements for bytes & bytearray [Python-Dev] PEP 467: Minor API improvements for bytes & bytearrayAntoine Pitrou antoine at python.org
Mon Aug 18 03:39:31 CEST 2014
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.


More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4