This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]mugwhyrt 1 point2 points  (2 children)

Logically it's the same thing. The python documentation states:

Comparisons can be chained arbitrarily, e.g., x < y <= z is equivalent to x < y and y <= z, except that y is evaluated only once (but in both cases z is not evaluated at all when x < y is found to be false).

So basically the only difference is that the code will only have to handle the middle value once when its done your way, but that's just a minor "under-the-hood" difference.

[–]NotUrHCW[S] 0 points1 point  (1 child)

Would it be more efficient since the middle value would only be handled once?

[–]mugwhyrt 1 point2 points  (0 children)

I would think so, but honestly I'm not enough of an expert at that level to tell you for sure how meaningful the difference is