[Twisted-Python] Surprises in twisted.web.woven

Bob Ippolito bob at redivi.com
Mon Aug 4 14:41:16 EDT 2003

On Monday, Aug 4, 2003, at 14:14 America/New_York, Phillip J. Eby wrote:

> At 12:28 PM 8/4/03 -0500, Glyph Lefkowitz wrote:
>> On Monday, August 4, 2003, at 07:13 AM, Tim Allen wrote:
>>> Is there any reason why white-space preserving should not always be 
>>> on?
>> Believe it or not, it's a bottleneck.
>> In order to preserve whitespace, you have to create a bunch of extra 
>> Node and str objects, which consume a not-inconsiderable set of 
>> resources for, let's say, a directory full of reasonably sized Woven 
>> templates.
>> This cost is exacerbated by the fact that woven copies and inspects 
>> the entire tree of DOM objects on every page render.
> You might be interested in the technique I use for peak.web.templates. 
>  First, my DOMlet objects aren't even as sophisticated as Twisted's 
> microdom; they are just objects that cwrite unicode streams.  Second, 
> each node has a 'staticText' attribute that can be either a unicode 
> value or None.  So, parent nodes can glom together adjacent nodes with 
> staticText.  Then, if that node only has static content, it defines 
> its own staticText attribute, so it can be glommed together with its 
> peers, by its parent.  The net result is that a template, as a whole, 
> consists of dynamic nodes occasionally interrupted by a block of 
> static text.

That's pretty much what donovan and I were doing with STAN back at 
pycon dc, but I don't think either of us tried very hard to actually do 
anything much with it after the fact.  It was a kind of "optimizing 
compiler" for templates.


More information about the Twisted-Python mailing list