18 Feb
2009
18 Feb
'09
12:58 p.m.
Raymond Hettinger
Even if it did improve you one app, that would be atypical. Most apps that test and add will do something inside the branch that consumes far more time than the contains test.
Sorry, that argument could be turned into an argument against *any* optimization. For example, "there's no need to optimize building dict literals, since most apps will do something with the dict that consumes far more time than building the dict". The assumption being that only optimizations which benefit a large class of applications should be attempted, which is bogus (are large classes of applications bottlenecked by dict literal creation? yet we have specialized opcodes for dict literal creation, and so on for lots of other things).