[C++-sig] [Numpy-discussion] Overloading sqrt(5.5)*myvector

Bruce Sherwood Bruce_Sherwood at ncsu.edu
Sun Dec 30 19:17:26 CET 2007


That doesn't sound like my problem. In VPython it's not that its vector 
class overrides a Python class. Rather there is overloading of operators 
involving the vector class. The rules for doing this in C++ and Boost 
worked with Numeric but not with numpy. It's not clear whether the 
problem is with Boost or numpy.

Bruce Sherwood

Maximilian Wilson wrote:
> On Dec 29, 2007 3:00 PM, Bruce Sherwood <Bruce_Sherwood at ncsu.edu> wrote:
>   
>> Thanks to those who made suggestions. There remains the question of why
>> operator overloading of the kind I've described worked with Numeric and
>> Boost but not with numpy and Boost. There is also the question of
>> whether it would pay for numpy to make what is probably an exceedingly
>> fast check and do much faster calculations of sqrt(scalar) and other
>> such mathematical functions.
>>     
>
> I think the problem you ran into with Numeric has to do with Python's
> optimizations for built-ins. In order to override members of e.g.
> class "dict," you have to provide a trivial subclass (or do something
> funny with a metaclass) because, I think, otherwise Python hard-wires
> method calls to the extension method instead of looking them up in
> __dict__. That's about all I know on the subject, unfortunately, but
> here's Guido on this issue:
>
> http://mail.python.org/pipermail/python-dev/2003-November/040070.html
>
> -Max
>
>
>   



More information about the Cplusplus-sig mailing list