4 ms·
Is this any more clear than an elif expression? I suppose the condition coming first is nice
by paulddraper 3y ago
Is this any more clear than an elif expression?
I suppose the condition coming first is nice
- Izkata 3y agoPersonally I find this a whole lot clearer. It's a table lookup, instead of a series of sequential checks (especially if you listen to your linter and have the elif version with the conditions and values on alternating lines, vs the conditions together in a vertical column like this).
- paulddraper 3y agoNot sure if this was the intent, but to anyone reading this....this dict doesn't have the perf benefits of a "table lookup"; in fact it's slower.
- Izkata 3y agoThe question was about readability, not performance.