Hi Greg,
On Wed, Mar 29, 2006 at 12:38:55PM +1200, Greg Ewing wrote:
I'm really thinking more about the non-inplace operators.
If nb_add and sq_concat are collapsed into a single slot,
it seems to me that if you do
a = [1, 2, 3]
b = array([4, 5, 6])
c = a + b
then a will be
Hi all,
On Tue, Mar 28, 2006 at 09:50:49AM -0800, Guido van Rossum wrote:
C extensions are my main worry -- OTOH if += for a list can already
passes arbitrary types as the argument, then any extension types
should be ready to expect this, right?
Yes, I don't think C extensions are going to
Armin Rigo wrote:
Hi Greg,
On Wed, Mar 29, 2006 at 12:38:55PM +1200, Greg Ewing wrote:
I'm really thinking more about the non-inplace operators.
If nb_add and sq_concat are collapsed into a single slot,
it seems to me that if you do
a = [1, 2, 3]
b = array([4, 5, 6])
c = a + b
Armin Rigo wrote:
So if we provide a complete fix, [].__add__(x) will be modified to
return NotImplemented instead of raising TypeError if x is not a list,
and then [1,2,3]+array([4,5,6]) will fall back to array.__radd__() as
before.
Ah, okay. That seems like it would work.
--
Greg
Tim Hochberg wrote:
Still, perhaps for Py3K it's worth considering
if PyNumber_InplaceAdd should only call __iadd__ and __add__, not
__radd__. Thus giving the target object complete control during inplace
adds.
That's probably reasonable, although it would break
the conceptual notion that
On 3/29/06, Greg Ewing [EMAIL PROTECTED] wrote:
Tim Hochberg wrote:
Still, perhaps for Py3K it's worth considering
if PyNumber_InplaceAdd should only call __iadd__ and __add__, not
__radd__. Thus giving the target object complete control during inplace
adds.
That's probably reasonable,
Hi Tim,
On Wed, Mar 29, 2006 at 08:45:10AM -0700, Tim Hochberg wrote:
Ouch. Assuming the same path is followed with tuples, I think that this
means the following behaviour will continue:
t = (1,2,3)
a = array([4,5,6])
t += a
t
array([5, 7, 9])
I fell into the same trap at
Hi Tim,
Oups, sorry. I only just realized my mistake and the meaning of your
message.
On Thu, Mar 30, 2006 at 09:27:02AM +0200, Armin Rigo wrote:
t = (1,2,3)
t += [4,5,6]
TypeError: can only concatenate tuple (not list) to tuple
t += array([4,5,6])
TypeError: ...
Hi,
On Mon, Mar 27, 2006 at 08:00:09PM -0800, Guido van Rossum wrote:
So for consistency we want a += b to also execute a.__iadd__. The
opcode calls PyNumber_InplaceAdd; I think that PyNumber_InplaceAdd
(and PySequence_InplaceConcat, if it exists) should test for both the
numeric and the
Travis E. Oliphant wrote:
I can't imaging anybody relying on an in-place operations to return a
different object, but we could make the change and run all the
NumPy/SciPy tests to see what happens.
I'm really thinking more about the non-inplace operators.
If nb_add and sq_concat are
Armin Rigo wrote:
[].__add__(5)
TypeError: can only concatenate list (not int) to list
Would that be much of a loss? It doesn't really
give you much more information than something like
Unsupported operand types for '+': list, int
and what it does give is based on the assumption
If you have Numeric or numpy installed try this:
#import Numeric as N
import numpy as N
a = range(10)
b = N.arange(10)
a.__iadd__(b)
print a
Result:
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
Contrast the returned output with
import numpy as N
a = range(10)
b =
On 3/27/06, Travis Oliphant [EMAIL PROTECTED] wrote:
If you have Numeric or numpy installed try this:
#import Numeric as N
import numpy as N
a = range(10)
b = N.arange(10)
a.__iadd__(b)
print a
Result:
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
Contrast the
On 3/27/06, Travis E. Oliphant [EMAIL PROTECTED] wrote:
Guido van Rossum wrote:
On 3/27/06, Travis Oliphant [EMAIL PROTECTED] wrote:
If you have Numeric or numpy installed try this:
#import Numeric as N
import numpy as N
a = range(10)
b = N.arange(10)
a.__iadd__(b)
print a
Travis E. Oliphant wrote:
I think this can be fixed easily by first checking the sequence slot for
a sq_concat function before calling PyNumber_InPlaceAdd.
However, if this *is* fixed, it looks like it's going to
break NumPy, in the sense that it will no longer be able
to force an arithmetic
15 matches
Mail list logo