[Python-Dev] collections.idset and collections.iddict? (original) (raw)
Alex Martelli aleaxit at gmail.com
Tue Mar 7 03:53:22 CET 2006
- Previous message: [Python-Dev] collections.idset and collections.iddict?
- Next message: [Python-Dev] collections.idset and collections.iddict?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On Mar 6, 2006, at 4:43 PM, Bob Ippolito wrote:
On Mar 6, 2006, at 4:14 PM, Guido van Rossum wrote: ... I wonder if this use case and the frequently requested case-insensitive dict don't have some kind of generalization in common -- perhaps a dict that takes a key function a la list.sort()? +1. I've wanted such a thing a couple times, and there is some precedent in the stdlib (e.g. WeakKeyDictionary would be a lot shorter with such a base class).
Seconded -- though at least in the cases I remember better what I
really needed was a list with such functionality (order was
significant, but I wanted 'in'-tests and find and remove calls to
work by id, not by ==) -- I ended up with a somewhat more complicated
solution (not just a list subclass, though that might perhaps be
simpler). In the case where I needed a dict, I inherited from
DictMixin and delegated some methods (with id(key) instead of key) to
a self.somedict -- if a dict could be built with a key function, the
solution would be both simpler and faster.
Alex
- Previous message: [Python-Dev] collections.idset and collections.iddict?
- Next message: [Python-Dev] collections.idset and collections.iddict?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]