Hacker News new | ask | show | jobs
by __s 768 days ago
Python actually does something pretty neat: it chains comparisons so that `x < y <= z` is like `x < y and y <= z` except y is only evaluated once

In linked code we can be confident that `0 <= 1`, so only `1 < ndim` should matter. In fact I'd expect peephole optimization to remove most of the code for `0 <= 1`

1 comments

I did not know that python fact. Thanks for sharing!