NotImplimentedError
George Sakkis
george.sakkis at gmail.com
Mon Jan 14 21:02:36 EST 2008
On Jan 14, 5:39 pm, Ben Finney <bignose+hates-s... at benfinney.id.au>
wrote:
> I think of NotImplemented as equivalent to None; it's useful as a
> sentinel value to set an attribute to in (e.g.) an abstract class.
My guess would be that it is more of an implementation performance
decision than semantic. Checking 'if result is NotImplemented' is much
faster than guarding the call with a try/except NotImplementedError
block, and since the motivation for NotImplemented was AFAIK rich
comparisons, the potential overhead could be substantial (e.g. a tight
'while i<j' loop that's executed millions of times). Semantically
though, 'return NotImplemented' looks odd compared to 'raise
NotImplementedError'.
George
More information about the Python-list
mailing list