Ian Kelly <ian.g.ke...@gmail.com>:

>>     j = (lambda: 3, lambda: j + 1)[j < 10]()

> Yes, the lambda approach falls victim to function calls being slow.

That's just a deficiency in the compiler. There's nothing there that
prevents the optimizer from translating the expression into the
equivalent if statement.

At any rate, the only issue at hand is the obviousness of the idiom. You
should generally choose the syntax that best expresses the logic of the
program.


Marko
-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to