viktor-ferenczi / genshi-compiler

Genshi markup template compiler
0 stars 0 forks source link

Implement py:with blocks without a nested function #4

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
We could optimize out a few nested functions corresponding to `py:with` blocks 
by keeping track of all the local variables declared at any given level of 
generated code. It would allow replacing those nested functions with 
temporarily saving of variable values, which would result in faster rendering.

Original issue reported on code.google.com by ferenczi.viktor on 15 Jul 2011 at 1:50

GoogleCodeExporter commented 9 years ago

Original comment by ferenczi.viktor on 16 Jul 2011 at 2:14

GoogleCodeExporter commented 9 years ago
It would result in less readable code if there are hidden variables. So I 
suggest flattening nested functions corresponding to `py:with` directives only 
if no variable is hidden from the outer scope. It would not remove the inner 
variables after the completion of the block, so it would not be a compatible 
solution later. The speed gain would need to be measured as well, it might not 
worth the effort.

Original comment by ferenczi.viktor on 16 Jan 2012 at 3:04