[Python-Dev] bytearray methods returning self... (original) (raw)
Dino Viehland dinov at microsoft.com
Tue Nov 18 22:01:44 CET 2008
- Previous message: [Python-Dev] [Python-3000] 2.6.1 and 3.0
- Next message: [Python-Dev] bytearray methods returning self...
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
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.
- Previous message: [Python-Dev] [Python-3000] 2.6.1 and 3.0
- Next message: [Python-Dev] bytearray methods returning self...
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]