[Baypiggies] Output generation - (string operations/triple quote/template)

wesley chun wescpy at gmail.com
Wed Feb 14 00:50:35 CET 2007


> > I consider the approach of interleaving
> > Python code with the target output hard to maintain. It goes back to the
> > Java Servlet approach and the many addon projects later to provide better
> > alternatives.
>
> Are you sort-of saying that having a separate template is like having a ".h" file, and that keeping code+data local in the program makes things easier to understand, and, therefore, perhaps Python needs to include better templating features?


what i'm reading from what wai-yip said is that when you have Python
code and are actively trying to maintain its structure, attempting to
interleave Python code along with, say XML, SQL, etc., is difficult to
maintain, because you will end up wrecking/ruining/destroying the
structure of at least one, if not all, just to maintain *structure*,
say nothing of anything else. there is also a hint of "what happens
when we try to allow insertion of (programming) logic inside a
structured document processing format like HTML." that's just what *i*
read... to each his/her own!

i understand dennis' logic in trying to preserve structure in his
code, and why he is doing it -- i've seen lots of code like this, and
to some extent, it works in JS, however, for large and/or long-running
Python applications, i cannot justify the CPU time and performance
lost in doing malloc()+realloc()+realloc()+realloc()+realloc()+realloc()+realloc()+realloc()+realloc()...,
not to mention any internal heap fragmentation that may result from
it.

here's a clip from the man page:
       The order and contiguity of storage allocated by successive  calls  to
       realloc()  is unspecified. The pointer returned if the allocation suc-
       ceeds shall be suitably aligned so  that  it  may  be  assigned  to  a
       pointer  to  any type of object and then used to access such an object
       in the space allocated (until the space is explicitly freed or reallo-
       cated).

my process mgmt background is now a little rusty, so remind me: does
the OS help "defrag" heap chunks at all during the lifetime of a
process?  if so, how often?  is it time- or capacity-based?

just curious,
-- wesley
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
"Core Python Programming", Prentice Hall, (c)2007,2001
    http://corepython.com

wesley.j.chun :: wescpy-at-gmail.com
python training and technical consulting
cyberweb.consulting : silicon valley, ca
http://cyberwebconsulting.com


More information about the Baypiggies mailing list