XSLT speed comparisons

Damian damian at nice.co.nz
Wed Sep 27 17:24:36 EDT 2006


Hi, I'm from an ASP.NET background an am considering making the switch
to Python. I decided to develop my next project in tandem to test the
waters and everything is working well, loving the language, etc.

What I've got is:
two websites, one in ASP.NET v2 and one in Python 2.5 (using 4suite for
XML/XSLT)
both on the same box (Windows Server 2003)
both using the same XML, XSLT, CSS

The problem is, the Python version is (at a guess) about three times
slower than the ASP one. I'm very new to the language and it's likely
that I'm doing something wrong here:

from os import environ
from Ft.Lib.Uri import OsPathToUri
from Ft.Xml import InputSource
from Ft.Xml.Xslt import Processor

def buildPage():
    try:
        xsluri = OsPathToUri('xsl/plainpage.xsl')
        xmluri = OsPathToUri('website.xml')

        xsl = InputSource.DefaultFactory.fromUri(xsluri)
        xml = InputSource.DefaultFactory.fromUri(xmluri)

        proc = Processor.Processor()
        proc.appendStylesheet(xsl)

        params = {"url":environ['QUERY_STRING'].split("=")[1]}
        for i, v in enumerate(environ['QUERY_STRING'].split("/")[1:]):
            params["selected_section%s" % (i + 1)] = "/" + v

        return proc.run(xml, topLevelParams=params)
    except:
        return "Error blah blah"

print "Content-Type: text/html\n\n"
print buildPage()

You can compare the development sites here:
asp: http://consultum.pointy.co.nz/about/team
python: http://python.pointy.co.nz/about/team

Cheers!




More information about the Python-list mailing list