[pypy-dev] numpypy problem - can't find augmented assignment methods

Maciej Fijalkowski fijall at gmail.com
Sat Mar 30 11:55:15 CET 2013


On Sat, Mar 30, 2013 at 1:56 AM, Kay F. Jahnke <_kfj at yahoo.com> wrote:
> Hi group!
>
> I'm running numpypy and I have a problem with augmented assignment
> statements. It looks to me like the relevant methods are simply absent from
> my numpypy array objects. Consider for example:
>
> $ pypy
> Python 2.7.3 (7e4f0faa3d51, Nov 16 2012, 16:56:51)
> [PyPy 2.0.0-beta1 with GCC 4.4.3] on linux2
> ...
>>>>> import numpypy as np
>>>>> a=np.array([1])
>>>>> b = a
>>>>> b is a
> True
>>>>> b *= 3
>>>>> b is a
> False
>>>>> b.__imul__
> Traceback (most recent call last):
>   File "<console>", line 1, in <module>
> AttributeError: 'ndarray' object has no attribute '__imul__'
>
> On numpy under CPython, 'b is a' evaluates to True, and np.ndarray.__imul__
> is present. I suppose since the method isn't there, the system is falling
> back to run __mul__ and assigns the result to a new object (after all b
> contains correct data after the *=), but for my application I want the
> in-place operation. I've browsed in circles for a while to find out what's
> wrong or, respectively, why it is as it is; there might be a simple answer
> to my problem, so I decided to ask for help :)
>
> With regards
>
> Kay

It's simply unsupported by now :)


More information about the pypy-dev mailing list