[Python-Dev] PEP 455: TransformDict

R. David Murray rdmurray at bitdance.com
Tue Oct 8 21:19:48 CEST 2013


On Tue, 08 Oct 2013 22:02:43 +0400, Yuriy Taraday <yorik.sar at gmail.com> wrote:
> There should be a way to avoid creation of the second dict when there is no
> need to store original keys. For example, email.message module doesn't
> store original headers as they are not needed. The same applies to web
> frameworks parsing HTTP headers or WSGI environment.

This is not true.  email.message *very carefully* preserves the original
header name, case and all [*], that's part of its mandate (faithfully
reproducing the original parsed message).

That said, email.message can't use transformdict, since email.message
needs a list-with-case-insensitive-keyed-lookup, not a dict, because it
also preserves the original *order* of the headers.  And it couldn't use
an orderedtransformdict, either, since it also has to preserve
*duplicate* headers.

--David

[*] currently it loses whitespace information in certain cases, but the
new header parser/folder is supposed to fix that...or will once I fix a
few more corner cases :)


More information about the Python-Dev mailing list