By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,386 Members | 1,727 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,386 IT Pros & Developers. It's quick & easy.

opinions comments needed for improving a simple template engine.

P: n/a
Hi, I wrote a small template engine called spytee.
Like any template enigne, it take a text(html) template file as input,
process the variable tags in the file, and display the resulted text.
The difference from most templates are: you can edit the template file
in the html editor(Frontpage, Dreamweaver, whatever), thus a near
Complete seperation of presentation and logic. It's very simple and
easy, you only need 3 types of tags to control display, I don't think
most controls like 'if' 'else' 'loop', should be in a template anyway.

It also compile the template input into a python program and store it
in the cache location if the template is newer. On the next request of
displaying the same file, it will execute the cached python program to
save time.

the download is
(there are 2 files: and a sample template html file, just
unzip/untar it to a directoy and excute it to see how it work)

I borrowed some code from phpbb template( which in turn borrowed from
Phplib template and smarty template)

I'm new to Python (used perl and php a lot), so I'l need your help on
improving the speed of this thing.
I only tested it on mod_python, it's faster than PyMeld and Tinpy.
However it's slower than mod_python PSP, especially when excuting large
loops, like displaying a 1000 row table. (I didn't test large ones like
cheetah, quixote etc.)
At first I thought it was regular expression that slow it down. But
after I get rid of re, I didn't see much improvement.
Pleasa try it, and any feedbacks is appreciated.

Jul 18 '05 #1
Share this Question
Share on Google+
1 Reply

P: n/a
the ONLY way to tell what is slow is to actually profile each of the
operations, that said, start with examining object creation / memory
allocation. string concationation usually does both . . .

Jul 18 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.