[Python-Dev] Assertions

Paul Prescod paulp@ActiveState.com
Tue, 21 Nov 2000 16:32:50 -0800


Tim Peters wrote:
> 
> ...
> 
> -1.  User input is never trustworthy.  Your and your users' software lives
> will be a lot happier if you stick to the rule that an assertion failure
> always (always!) announces a bug in the implementation -- assertion failure
> is never a user's fault.  

So you prefer

if __debug__ and node.nodeType!=ELEMENT_TYPE: 
    raise TypeError

Unfortunately there's no way to turn that off at "compile time" so you
always incur the __debug__ lookup cost. That would send us back to two
versions of the methods.

Maybe testing would indicate that the performance implications are
minor. If so, I wouldn't mind having the type checks in there.

 Paul Prescod