[Python-Dev] PEP 455: TransformDict
Victor Stinner
victor.stinner at gmail.com
Fri Oct 4 23:06:15 CEST 2013
2013/10/4 Raymond Hettinger <raymond.hettinger at gmail.com>:
> * Another issue is that we're accumulating too many dictionary
> variants and that is making it difficult to differentiate and choose
> between them. I haven't found anyone (even in advanced classes
> with very experienced pythonistas) would knew about
> all the variations: dict, defaultdict, Mapping, MutableMapping,
> mapping views, OrderedDict, Counter, ChainMap, andTransformDict.
Ok, but none of these classes address use cases described of the PEP 455.
If it became hard to choose the best container for an use case, it's
maybe a documentation issue.
The PEP 455 contains a long list of existing implementations, so it
means that these use cases are common (even if the Python stdlib
according to the PEP). It's a good thing that Python proposes a
standard implementation (efficient, well tested, documented, etc.) to
answer to these use cases.
I'm not convinced by your usability test. The problem is maybe the
name, TransformDict. We may find a more explicit name, like
TranformKeyDict or NormalizedKeyMapping. Or we can use names of the
Transformers movies: OptimusPrimeDict, BumblebeeMapping,
JazzDictionary, etc.
(If we cannot find a better name, we may add more specialized classes:
KeyInsensitiveDict and IdentiyDict. But I like the idea of using my
own "transform" function.)
Victor
More information about the Python-Dev
mailing list