4 ms·
The difference in your "which of the two look better" example is: (a) has one dict operation plus an exception which rarely occurs and is nearly zero cost if i
by stevesimmons 5y ago
The difference in your "which of the two look better" example is:
(a) has one dict operation plus an exception which rarely occurs and is nearly zero cost if it doesn't.
versus
(b) has nearly always two dict operations, plus a possibly incorrect assumption that the dict will not be mutated between the "if key in dict" and "dict[key]" operations.