[Numpy-discussion] Template system

Charles R Harris charlesr.harris at gmail.com
Fri Jan 11 21:24:04 EST 2008


On Jan 11, 2008 7:02 PM, Robert Kern <robert.kern at gmail.com> wrote:

> Charles R Harris wrote:
> >
> >
> > On Jan 11, 2008 2:58 PM, Robert Kern <robert.kern at gmail.com
> > <mailto:robert.kern at gmail.com>> wrote:
> >
> >     Charles R Harris wrote:
> >      > Hi All,
> >      >
> >      > I'm thinking of adding the template system I pulled out of Django
> to
> >      > Numpy to use in place of the current code generator. Its
> >     advantages are
> >      > documentation, flexibility, and maintainance. The code totals
> >     about 470
> >      > KB, comes with a BSD license, and is compatible with Python >=
> 2.3. I
> >      > want to bring this up on the list because I'm sure there will be
> >      > objections along the lines of "why do we need that"?  So I want
> >     to see
> >      > how strenuous the objections are.
> >
> >     It's too big. If you want a better template system than the current
> >     one, there
> >     are a few which are contained in a single file. That would be fine
> >     to include,
> >     but I object strongly to incorporating Jinja.
> >
> >
> > Ummm, harsh. I'm certainly open to suggestions. I took a closer look at
> > the django system and reduced it to 308K, 70K zipped. There was a lot of
> > space taken up by the .svn directories inherited from django and *.pyc
> > files. I could probably knock another 50K off by removing some
> > functionality we don't really need: html, http, dates, time, and maybe
> > template inheritance. Just for comparison, here are some things that are
> > in a fresh checkout of numpy, including the .svn files
> >
> > Numpy 23 MB
> > f2py   5.4 MB
> > doc/swig 1.5 MB
> > code_generators 192K
> >
> > So adding the template subsystem would increase the repository size by
> > about 1.4%.  Do you have any objections in addition to the size?
>
> Yes. I'm not convinced that we need anything better than we have now. Show
> me
> how using Jinja templates makes the current code better. Check the
> one-file
> templating modules (like YAPTU[1] or Cog[2]) out there to see if those are
> sufficient. Jinja and its kin (Mako, Cheetah, etc.) are intended for a
> very


YAPTU lacks any sort of control structures in the markup, in fact, it
doesn't  *have* markup. This has several consequences.

1) You have to write code with all the loops and substitutions. That's work.
2) Someone has to document the markup they decide to use.
3) It won't be obvious from looking at the template what is going to happen.

YAPTU is a step down from what we have now. Indeed, what we have now has
something like YAPTU built in.

Cog is 109KB and has the same problems as YAPTU, except the code is now part
of the template, totally messing up the separation of view and model, and it
is excessively ugly to look at (IMHO).

I suspect we could find many uses for a template capability because folks
haven't been thinking that way. I wonder if f2py couldn't make use of such a
facility? As to the usual use of Cheetah and such in web serving, common
problems lead to common solutions. It's an example of convergent evolution,
not an insult. I picked Django over Cheetah as a starting point because I
thought the markup was much better looking.

Chuck
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20080111/aaf239de/attachment.html>


More information about the NumPy-Discussion mailing list