templates

Peter Hansen peter at engcorp.com
Tue Jan 31 06:20:32 EST 2006


Christoph Zwerschke wrote:
> thakadu schrieb:
> 
>>I have used PyMeld (http://www.entrian.com/PyMeld/) which is one of
>>very few that gives a 100% separation of code and presentation, in fact
>>PyMeld is not strictly speaking a template system at all.
> 
> Yes, it is more like XIST that I mentioned in another post.
> The reason why this is slower than native templates seems clear: You 
> convert the whole page to objects in memory, and then serialize 
> everything back to HTML. If you are only filling in a few words, then 
> native templates will be surely much more effective. But if you are 
> messing around with the structure of your page, inserting and adding 
> elements, then PyMeld will be probably a better way.

Unless I'm misremembering, PyMeld is special amongst the "total 
decoupling of code and presentation" crowd in that it does *not* convert 
the whole page to objects in memory, but instead performs its operations 
using regular-expression substitution, and serializing back to HTML is a 
trivial operation since it's already serialized.

I'm sure the extra overhead versus simple % substitution is noticeable, 
but I have to say I was surprised to hear that it was measured at two 
orders of magnitude slower.  I thought better performance (versus the 
"manipulate in-memory as DOM" approach) was one of its advantages.

-Peter




More information about the Python-list mailing list