I am unsure if the assert section in defensive programming should be updated to contain a note that assert statements are primarily debug tools / checking assumptions and should not be relied upon to do critical data validation as they will not necessarily be included if optimisations are requested:
https://docs.python.org/3/reference/simple_stmts.html#the-assert-statement