[Python-Dev] byte literals unnecessary [Was: PEP 332 revival in coordination with pep 349?]

Neil Schemenauer nas at arctrix.com
Wed Feb 15 00:38:33 CET 2006


On Tue, Feb 14, 2006 at 03:13:37PM -0800, Guido van Rossum wrote:
> Also, bytes objects are (in my mind anyway) mutable. We have no other
> literal notation for mutable objects. What would the following code
> print?
> 
>   for i in range(2):
>     b = b"abc"
>     print b
>     b[0] = ord("A")
> 
> Would the second output line print abc or Abc?
>
> I guess the only answer that makes sense is that it should print abc
> both times; but that means that b"abc" must be internally implemented
> by creating a new bytes object each time. Perhaps the implementation
> effort isn't so minimal after all...

I agree.  I was thinking that bytes() would be immutable and
therefore very similar to the current str object.  You've convinced
me that a literal representation is not needed.  Thanks for
clarifying your position.

> (PS why is there a reply-to in your email the excludes you from the
> list of recipients but includes me?)

Maybe you should ask your coworkers. :-)  I think gmail is trying to
do something intelligent with the Mail-Followup-To header.

  Neil


More information about the Python-Dev mailing list