[Python-Dev] Add a "transformdict" to collections
Antoine Pitrou
solipsis at pitrou.net
Wed Sep 11 15:04:23 CEST 2013
Le Wed, 11 Sep 2013 22:47:12 +1000,
Nick Coghlan <ncoghlan at gmail.com> a écrit :
>
> I'll join the chorus requesting that this live on PyPI for a while
> first.
>
> I think this is a case similar to what happened with
> contextlib.ExitStack: I'm not sure if anyone actually *used*
> contextlib2 for anything significant (if they did, they didn't tell me
> about it), but just going through the process of properly documenting,
> publishing and testing it as a relatively independent project forced
> *me* to think through the design.
ExitStack was quite a new thing, API-wise. The proposal here is to
generalize something which already exists in various forms all over the
Internet, and respecting a well-known API, MutableMapping.
There are not many possible APIs to create case-insensitive dicts, or
identity dicts. The only API contention until now has been about
whether the first or last key would be retained (which settled on
the former), and Serhiy's three instantiation schemes.
The additional methods you suggest may be nice to have, but they are
not necessary and (deliberately) not part of the original proposal. That
is, they can be grafted later on.
> As my preferred bikeshed colour, I'm going to suggest "MappedKeyDict"
> (using a similar naming style to OrderedDict),
Ha, another colour! Thanks :-)
Regards
Antoine.
More information about the Python-Dev
mailing list