[Python-Dev] Decimal & returning NotImplemented (or not)

Nick Coghlan ncoghlan at iinet.net.au
Wed Mar 2 11:28:58 CET 2005

Nick Craig-Wood wrote:
> Why is it like that?

Speed, I assume - if it was exception based, then *every* operation effectively 
gets wrapped in a try/except block. Yikes!

Also, for C implementations, the error return is fairly natural. It's only when 
implementing operations in Python that it bites.

>  And could it be changed (Nick Coghlan's proposal
> seems good to me)?

Take a look at my latest suggestion using OperatorTypeError and operatormethod. 
(which makes it easy to put the try/catch block in place if you want it, while 
still leaving it out for the common case).


Nick Coghlan   |   ncoghlan at email.com   |   Brisbane, Australia

More information about the Python-Dev mailing list