I love assert
ethan at stoneleaf.us
Fri Nov 14 21:41:09 CET 2014
-----BEGIN PGP SIGNED MESSAGE-----
On 11/14/2014 11:12 AM, Marko Rauhamaa wrote:
> Ethan Furman wrote:
>> 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.
On this point we can agree. :)
>> 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?
In the handful of languages I have worked with so far, it's the other way 'round: you un-optimize debug mode in.
CPython itself is a good example: when configuring, you must add --with-pydebug in order to get all the extra checks
added (which is great when adding new features), but that option isn't used when making production CPythons; yet
Python the language is just the opposite: debug mode is on /by default/, and to turn it off you have to specify -O:
$ ./python -c "print(__debug__)"
$ ./python -O -c "print(__debug__)"
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)
-----END PGP SIGNATURE-----
More information about the Python-list