0

In java you can speed up execution of the boolean expression if using a double operand like && or ||.

Is there anything like this in python?

Clarification for those unfamiliar with Java: When I have a logical Java expression consisting of several parts, e.g. p & q & r, at runtime JRE will have to evaluate every part to get the result. If I am writing this as p && q && r, and say my p is false, JRE will stop evaluating the whole expression before reaching q and will return False.

afora377
  • 364
  • 2
  • 4
  • 13
  • That's called "short circuiting" btw. And, it should be noted that that's not the main difference between `&` and `&&`. `&` is bitwise AND, `&&` is logical AND. – Carcigenicate Aug 30 '17 at 00:32
  • I'm not sure what you mean. The behavior you describe after "Clarification for those unfamiliar with Java:" is known as "short circuiting". The link I posted answers your question. – Carcigenicate Aug 30 '17 at 00:36

0 Answers0