[Bengt Richter] > IMO Raymond's Zen concerns > are the ones to think about first, and then efficiency, which was one of the motivators > in the first place ;-)
Well said. I find the disassembly (presented in the first post) to be telling. The compiler has done a great job and there is no fluff -- all of those steps have been specified by the programmer and he/she must at some level be aware of every one of them (pre-instantiation, multiple method lookups and calls, multiple dictionary accesses, etc). That is too bad because the intent could have been stated atomically: d.appendlist(k, v). Instead, the current idiom turns you away from what you want done and focuses the attention on how it is done: d.setdefault(k, []).append(v). That is too many steps for what should be an atomic operation (in the eyes of the programmer and code readers). Likewise, d.tally(k) is as atomic as this expression can get. Any other steps, added verbiage, new types, extra arguments, or whatnot are an unnecessary waste of brain cells. Raymond Hettinger -- http://mail.python.org/mailman/listinfo/python-list