[Python-Dev] Assertions

uche.ogbuji@fourthought.com uche.ogbuji@fourthought.com
Tue, 21 Nov 2000 23:23:14 -0700


> 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.

Of course, continuations would be perfect here, as one could set the 
continuation to resume after the check if he wished to bypass it.

Something tells me I should duck now...

not-very-seriously-mind-you'ly yrs

-- 
Uche Ogbuji                               Principal Consultant
uche.ogbuji@fourthought.com               +1 303 583 9900 x 101
Fourthought, Inc.                         http://Fourthought.com 
4735 East Walnut St, Ste. C, Boulder, CO 80301-2537, USA
Software-engineering, knowledge-management, XML, CORBA, Linux, Python