[Twisted-Python] Surprises in twisted.web.woven
Phillip J. Eby
pje at telecommunity.com
Mon Aug 4 12:14:51 MDT 2003
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.
More information about the Twisted-Python
mailing list