For review: PEP 308 - If-then-else expression
Andrew Dalke
adalke at mindspring.com
Sat Feb 8 19:32:30 EST 2003
Paul Moore:
> I'd be interested to know how many real cases would actually rely on
> short-circuit evaluation.
I looked at about 30 examples in the Linux kernel. Few needed it, though
I don't reacall the numbers. I looked at 16 different kinds of uses
of ?: in a proprietary C++ codebase I have access to. Only a couple
needed it, in the form "p == NULL ? 0 ? p->method()". More often
it was incorrectly or confusingly used, or used as a replacement for
min/max.
My best estimates are about one use of if/else expression per
1,000 lines of Python code, for the population who is writing
code in my field, so figure 1 in 4,000 lines where short-circuiting
is needed.
Results posted elsewhere.
Andrew
dalke at dalkescientific.com
More information about the Python-list
mailing list