[Numpy-discussion] Asking for opinions: Priops

Sebastian Walter sebastian.walter@gmail....
Wed Sep 22 14:31:43 CDT 2010


Hello Friedrich,

I have read your proposal. You describe issues that I have also
encountered several times.
I believe that your priops approach would be an improvement over the
current overloading of binary operators.
That being said, I think the issue is not so much numpy but rather the
way Python implements operator overloading using methods like __add__
and __radd__.  Hence, your suggestion seems to be a Python Enhancement
Proposal and should be discussed without any references to numpy or
bugs related to numpy.set_numeric_ops.
Maybe you could also have a look at Go's interfaces (Googles
programming language) which seems to be somewhat related to your
approach. Also, have you checked the Python mail archive? Issues like
that tend to be discussed from time to time.

On a more practical note: Why exactly do you use set_numeric_ops? You
could also
1) use numpy.ndarrays with dtype=object
2) or create new numpy.ndarray -like class and set  __array_priority__ > 2
both approaches work well for me.

just my 2 cents,
Sebastian



On Thu, Sep 16, 2010 at 2:02 PM, Friedrich Romstedt
<friedrichromstedt@gmail.com> wrote:
> I just ran across the problem of priorities with ndarrays again and it
> keeps biting me.  I did once ago a workaround to get my ``undarray``
> class's methods be called when being the second operand of e.g.
> <ndarray> + <undarray>.  But since I wrote it, always Python crashes
> on exit with the message:
>
> Python-32(68665) malloc: *** error for object 0x239680: incorrect
> checksum for freed object - object was probably modified after being
> freed.
> *** set a breakpoint in malloc_error_break to debug
>
> (Of course only if I imported the module.  Occasionally I also
> observed Bus errors, and even segfaults.)
> I overloaded the numpy ops via numpy.set_numeric_ops() with
> self-written classes, which are *not* derived from numpy.ufunc, and do
> not resemble numpy ufuncs completely.
>
> So I want to do it properly this time.
>
> I therefore started with writing a Letter of Intent, and put it online
> on http://github.com/friedrichromstedt/priops .
>
> Opinions?
>
> Friedrich
>
> P.S.: I will start coding anyway, but it would be nice.
>
> P.P.S.: The package this originates from is also online, under
> http://github.com/friedrichromstedt/upy, or
> http://upy.sourceforge.net.  I will probably create a small example
> script demonstrating the crash.
> _______________________________________________
> NumPy-Discussion mailing list
> NumPy-Discussion@scipy.org
> http://mail.scipy.org/mailman/listinfo/numpy-discussion
>


More information about the NumPy-Discussion mailing list