#3529: Context.update doesn't do what it says it does
---------------------------+------------------------------------------------
Reporter: SmileyChris | Owner: adrian
Status: new | Component: Template system
Version: SVN | Resolution:
Keywords: | Stage: Design decision needed
Has_patch: 1 | Needs_docs: 0
Needs_tests: 0 | Needs_better_patch: 0
---------------------------+------------------------------------------------
Comment (by [EMAIL PROTECTED]):
I believe the reason why you see slowdown in variable lookup when
implementing my suggestion is because {{{Context.__getitem__}}} needs to
be changed when the dicts list order is reversed.
If you reverse the list, you also need to reverse variable lookup. ATM we
have:
{{{
#!python
def __getitem__(self, key):
"Get a variable's value, starting at the current context and going
upward"
for d in self.dicts:
if key in d:
return d[key]
raise KeyError(key)
}}}
{{{for d in self.dicts}}} should be changed to {{{for d in
reversed(self.dicts)}}} (or some python 2.3 compatible construct). Then
there shouldn't be any noticeable difference in variable lookup with the
other version (as lists elements are accessed in constant time in Python).
Unfortunately I am not in a position to test this right now.
--
Arnaud
--
Ticket URL: <http://code.djangoproject.com/ticket/3529#comment:6>
Django Code <http://code.djangoproject.com/>
The web framework for perfectionists with deadlines
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/django-updates?hl=en
-~----------~----~----~----~------~----~------~--~---