opinions comments needed for improving a simple template engine.

W

Wensheng

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 www.pytan.com/download/spytee.tar.gz
(there are 2 files: spytee.py 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.
 
F

fuzzylollipop

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 . . .
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,754
Messages
2,569,521
Members
44,995
Latest member
PinupduzSap

Latest Threads

Top