What can I do to maximize the peformance of a dtml-in statement? When iterating over a 2000 row database query, it takes about 20 seconds - time mostly spent doing security checks, and calling __getitem__ in DT_InSV.py. Is the performance of dtml-in just slow? -Brett
Another performance consideration with looping in DTML is that whatever is in your DTML block is reinterpreted each time through. Although it is parsed (hopefully) only the first time through, this overhead is still considerable when multiplied over 2000 rows. You are essentially using an interpreter (Python) as an interpreter for DTML. I would seriously consider moving this entire operation (query, iteration and html generation) to native Python if performance is a big consideration.
We have had similar performance problems with the first version of our Content Management demo. It used both dtml-in loops and ZClasses (with other ZCLasses as base classes) heavily. The combination of the both can be very efficient in slowing down Zope. I remember the first versions of Martijn Faassen's XML-Widgets that had a similar performance problem. The reason is that in addition to the dtml-in overhead ZClasses take a lot of time for acquiring from their containers and inheriting from their "base classes" as all the inheritance stuff is only simulated - in fact almost everything is just stored in property sheets and has to be processed by the security engine if I got it right. In Python these problems go away. Maybe it is time for a good reimplementation of ZClasses, inlcuding the creation of REAL Python classes in the filesystem on the fly. BTW: Does anybody know if the Zope Page Templates (ZPT) parser is faster with looping than the DTML one? Cheers, Joachim.