I love assert

Marko Rauhamaa marko at pacujo.net
Fri Nov 14 20:12:41 CET 2014


Ethan Furman <ethan at stoneleaf.us>:

> My point being: a safety net that is so easily disabled does not count
> (IMHO) as a backup.

Correct. You never lean on assertions. They are primarily formal
comments.

However, assertion failures do help in troubleshooting occasionally.
Most importantly, they immediately, unquestionably point the finger at
the developer.

> This is one my very few complaints about Python: running it normally
> is the same as running with DEBUG turned on, so the unusual case is
> remembering to run with asserts turned /off/.

I don't remember ever having optimized them out in any programming
language. Has that really improved the performance of your code?


Marko



More information about the Python-list mailing list