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/2008-November/083599.html below:

[Python-Dev] bytearray methods returning self...

[Python-Dev] bytearray methods returning self... [Python-Dev] bytearray methods returning self...Dino Viehland dinov at microsoft.com
Tue Nov 18 22:30:12 CET 2008
Sure, it's now bug 4348 - http://bugs.python.org/issue4348

-----Original Message-----
From: gvanrossum at gmail.com [mailto:gvanrossum at gmail.com] On Behalf Of Guido van Rossum
Sent: Tuesday, November 18, 2008 1:14 PM
To: Dino Viehland
Cc: python-dev at python.org dev
Subject: Re: [Python-Dev] bytearray methods returning self...

Good catch, this is a bug IMO and we should fix it in 2.6.1 and 3.0rc3.

Mind filing a bug so we can keep track of it?

--Guido

On Tue, Nov 18, 2008 at 1:01 PM, Dino Viehland <dinov at microsoft.com> wrote:
> I've been implementing bytearray for IronPython and I noticed a couple of spots where the non-mutating methods of bytearray return self.
>
> In 2.6 but not in 3.0 RC2:
>
> x = bytearray(b'abc')
> y = x.replace(b'abc', b'bar', 0)
> id(x) == id(y)
>
> In 2.6 and in 3.0 RC2:
>
> t = bytearray()
> for i in range(256): t.append(i)
>
> x = bytearray(b'')
> y = x.translate(t)
> id(x) == id(y)
>
> Given that bytearray always returns a new instance on all of the other methods shouldn't it return a new instance here as well?  I'm just thinking someone could be planning on mutating the result here and not expecting their original bytearray to be mutated.

--
--Guido van Rossum (home page: http://www.python.org/~guido/)

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