TODO
This file
Path
TODO
39 lines · 1.2 KiB
Last changed by
removed unused importsArmin Ronacherbefore adoption981cbf6
History of this fileTake it
improved variable exporting, added TODO fileArmin Ronacherbefore adoption69e12db
lines 1–39why, one step back1Todo Before Release2===================34This has to be implemented before the release:56Pull Attributes Onces7---------------------89Imagine the following template::1011 {% if foo.bar %}12 {{ baz(foo.bar) }}13 {% endif %}1415Problem with that is that it compiles to this::1617 if environment.subscribe(l_foo, 'bar'):18 if 0: yield None19 yield u'\n %s\n' % (20 l_baz(environment.subscribe(l_foo, 'bar')),21 )2223As `environment.subscribe` is more expensive then regular attribute lookups24(it tries getitem/getattr and in sandbox mode also permissions) multiple25lookups with the same parameters in the same scope should get local aliases.26The result we have is that one::2728 t1 = environment.subscribe(l_foo, 'bar')29 if t1:30 if 0: yield None31 yield u'\n %s\n' % (32 l_baz(t1),33 )3435However that should only happen if the attribute is accessed multiple times36unlike locals and filters/tests which are always pulled. We're not doing that37for filters/tests/locals as nested scopes may access it and testing is too38complicated for the tiny performance improvement but easy for attribute39lookups, keeping the complexity of the whole thing in mind.