Re: Decimal, __radd__, and custom numeric types...

2005-03-02 Thread Nick Coghlan
Blake T. Garretson wrote: Thanks for the suggestions and modified module. I will probably just use this fixed module to solve my immediate problem. Expect its performance to be worse than the standard version - it does the right thing, but it sure ain't pretty. . . Cheers, Nick. -- Nick Coghlan

Re: Decimal, __radd__, and custom numeric types...

2005-03-01 Thread Nick Coghlan
Blake T. Garretson wrote: If Decimal objects prematurely throw a TypeError before trying the __rop__, is Decimal broken, or was it designed this way? I suspect the former, since I can't recall this subject coming up at any point during the PEP approval or implementation process. And I was one of

Re: Decimal, __radd__, and custom numeric types...

2005-03-01 Thread Nick Coghlan
Nick Coghlan wrote: a) Checking that replacing the relevant raise TypeError calls in Lib/Decimal.py with return NotImplemented gives you friendlier behaviour. It turns out this isn't really practical - there's too much code in the module relying on those TypeErrors being raised. So this may

Re: Decimal, __radd__, and custom numeric types...

2005-03-01 Thread Nick Coghlan
Nick Coghlan wrote: Nick Coghlan wrote: a) Checking that replacing the relevant raise TypeError calls in Lib/Decimal.py with return NotImplemented gives you friendlier behaviour. It turns out this isn't really practical - there's too much code in the module relying on those TypeErrors being

RE: Decimal, __radd__, and custom numeric types...

2005-03-01 Thread Batista, Facundo
Title: RE: Decimal, __radd__, and custom numeric types... [Nick Coghlan] #- a) Checking that replacing the relevant raise TypeError #- calls in #- Lib/Decimal.py with return NotImplemented gives you friendlier #- behaviour. #- #- #- It turns out this isn't really practical

Re: Decimal, __radd__, and custom numeric types...

2005-03-01 Thread Nick Coghlan
Batista, Facundo wrote: [Nick Coghlan] #- a) Checking that replacing the relevant raise TypeError #- calls in #- Lib/Decimal.py with return NotImplemented gives you friendlier #- behaviour. #- #- #- It turns out this isn't really practical - there's too #- much code in the #- module relying

Re: Decimal, __radd__, and custom numeric types...

2005-03-01 Thread Blake T. Garretson
Thanks for the suggestions and modified module. I will probably just use this fixed module to solve my immediate problem. I appreciate your post to python-dev as well; it looks like this may be addressed in a future release. :) Thanks, Blake --

Decimal, __radd__, and custom numeric types...

2005-02-28 Thread Blake T. Garretson
I'm having some issues with decimal.Decimal objects playing nice with custom data types. I have my own matrix and rational classes which implement __add__ and __radd__. They know what to do with Decimal objects and react appropriately. The problem is that they only work with Decimals if the

Re: Decimal, __radd__, and custom numeric types...

2005-02-28 Thread Nick Craig-Wood
Blake T. Garretson [EMAIL PROTECTED] wrote: I'm having some issues with decimal.Decimal objects playing nice with custom data types. I have my own matrix and rational classes which implement __add__ and __radd__. They know what to do with Decimal objects and react appropriately. The

Re: Decimal, __radd__, and custom numeric types...

2005-02-28 Thread Kanenas
On 28 Feb 2005 12:11:33 -0800, Blake T. Garretson [EMAIL PROTECTED] wrote: [...] From the Python docs (specifically sections 3.3.7 and 3.3.8), I thought that the left object should try its own __add__, and if it doesn't know what to do, THEN try the right object's __radd__ method. To me it