[Python-Dev] PEP 455: TransformDict

Antoine Pitrou solipsis at pitrou.net
Tue Oct 8 14:30:02 CEST 2013


Le Tue, 8 Oct 2013 22:12:02 +1000,
Nick Coghlan <ncoghlan at gmail.com> a écrit :
> 
> It's OK if the key transforming API has to constrain the behaviour of
> the underlying mapping or require an appropriately designed transform
> function to handle more esoteric containers. Either would still be
> better than categorically *disallowing* composition to the point
> where you can't even compose it with OrderedDict.

Well, you could ask the same question about OrderedDict, defaultdict or
Weak*Dictionary since neither of them use composition :-)

> ChainMap doesn't
> compose sensibly with arbitrary mappings like defaultdict, but
> composition is still the right design choice because it works well
> with *most* custom mappings.

ChainMap is easy to compose since it doesn't have to keep any
data-driven internal state.

> It's not that I think this is necessarily a *bad* idea (although the
> composability problem gives me grave doubts), it's that I think it's
> not an *urgent* idea, so why rush to review and include it in the
> weeks remaining before the beta, when the option of publishing it as
> a recipe or a PyPI module remains available?

It's just that I disagree we're rushing anything. The feature is fairly
simple, many people have already had a need for something like that.
(and amongst those people absolutely *zero* have said the design of the
feature proposal is inadequate)

Regards

Antoine.




More information about the Python-Dev mailing list