On 11/05/2014 05:16 PM, Tim Graham wrote: > Nice work on the DEP. I tend to agree with Carl that I like a 'NAME' key > in TEMPLATES rather than requiring the use of OrderedDict, but I can > also see why you don't. I think it might simply the implementation if > TEMPLATES was always a list of dictionaries rather than allowing it to > be a dict or an OrderedDict. But if you decide not to go that route: if > Django iterates over a plain dict to select a template, it seems that > could result in some weird performance issues, e.g. if a page that > expects template loader 'A' and sometimes tries 'A' as the first loader, > sometimes as the second, etc (assuming there is some performance penalty > for trying a loader and not finding the template). If it were me, I > think I'd always enforce ordering if len(TEMPLATES) > 1 as Carl > suggested. If the only downside is the ugliness of OrderedDict, well I > think it might save some headaches and support queries.
Yes, I'm still a bit uneasy with the idea of even allowing a multi-engine `TEMPLATES` to be an unordered dict as well. I hadn't thought about the fact that it is relevant for performance reasons even if you aren't doing any template overrides. It just seems like a bad idea to allow it at all. And like Tim, I do feel that a `NAME` key would also still be a reasonable alternative, even though it breaks the parallel with `DATABASES` and `CACHES` (there is not really a parallel anyway, since those are unordered mappings, which is a different data structure). On the other hand, I do recognize that the name is by nature a referent (and should be unique), and thus having it be the key in a mapping makes a lot of sense. Seeing the `OrderedDict` syntax in the example in the latest PEP update made me sad. So much more verbose than dictionary syntax; I think people will really be tempted to skip it if we don't force ordered-ness, but I think unordered will cause them even more problems. Sure wish Python had builtin syntax for ordered mappings :/ Carl -- You received this message because you are subscribed to the Google Groups "Django developers (Contributions to Django itself)" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/django-developers. To view this discussion on the web visit https://groups.google.com/d/msgid/django-developers/545AC154.7020102%40oddbird.net. For more options, visit https://groups.google.com/d/optout.
