funkybob / knights-templater

One more Python templating engine won't hurt, surely?
http://knights-templater.readthedocs.org/en/latest/
MIT License
7 stars 1 forks source link

Analyse locals to promote context variables into local scope #9

Open funkybob opened 9 years ago

funkybob commented 9 years ago

Instead of mangling Name nodes to become context lookups, we can promote values out of the context into the local scope for mind bogglingly fast lookups.

We'd have to be careful of any nested scopes, like "with".

Also make sure to fall back to the global scope properly.

funkybob commented 9 years ago

We can move the burden of updating the context from for to block potentially... this would mean pushing locals() into the scope stack around the yield from.

funkybob commented 8 years ago

If we scan the blocks of code in each call to Parser.build_method we can write the function to accept the args it needs, and \ context.

However, we would also need to track all block calls so we pass these variables onto them.

Would also require for tags, and anything else, to (temporarily) update this list.