Raymond Hettinger wrote: > I would like to get everyone's thoughts on two new dictionary methods:
+1 for each. > PROBLEMS BEING SOLVED > --------------------- > > The readability issues with the existing constructs are: > > * They are awkward to teach, create, read, and review. > * Their wording tends to hide the real meaning (accumulation). > * The meaning of setdefault() 's method name is not self-evident. +1 to EACH of the above 3 points. A question directed to the folk who had to look up "tally" in the dictionary: Which dictionary includes "setdefault", "updateBy", etc? > > The performance issues with the existing constructs are: [MANY] > the performance improvement matches the readability > improvement. Agreed. > > > ISSUES > ------ > > The proposed names could possibly be improved (perhaps tally() is more active > and clear than count()). +3 for tally !!! appendtolist is better than appendlist > > The appendlist() method is not as versatile as setdefault() which can be used > with other object types (perhaps for creating dictionaries of dictionaries). > However, most uses I've seen are with lists. My use cases for tally: (1) Yes the text-book "word" frequency gig applied in production data-matching etc applications (2) quick stats like from SQL "group by" e.g. customer.tally(state) customer_value.tally(state, dollar_value) # real or *DECIMAL* Use cases for appendlist: many; in general, how else do you implement a one-to-many relationship in memory?? -- http://mail.python.org/mailman/listinfo/python-list