Anything equivalent to cassert in C++?

P

Peng Yu

There are some assertion code (testing if a condition is false, if it
is false, raise an Error object) in my python, which is useful when I
test my package. But such case would never occur when in the produce
code. If I keep them in if statement, it will take some runtime. I'm
wondering what is the practice that take care of the assertion code in
python.
 
A

Aahz

There are some assertion code (testing if a condition is false, if it
is false, raise an Error object) in my python, which is useful when I
test my package. But such case would never occur when in the produce
code. If I keep them in if statement, it will take some runtime. I'm
wondering what is the practice that take care of the assertion code in
python.

You should be very careful not to put unit tests in asserts because that
prevents you from testing your application under optimization.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,781
Messages
2,569,616
Members
45,306
Latest member
TeddyWeath

Latest Threads

Top