Re: [PATCH] Remove unnecessary dir()/set() calls in Template.__init__()

Aahz <[email protected]> Tue, 13 Oct 2009 05:59:55 -0700
Newsgroups gmane.comp.python.cheetah
Organization The Cat & Dragon
Message-ID <[email protected]>
On Mon, Oct 12, 2009, R. Tyler Ballance wrote:
>
> When running cheetah.Tests.Performance.DynamicMethodCompilationTest
> with 100000 iterations set, Template.__init__() is the most performance
> sensitive call.

This seems like a safe change.  I would even go a step further in
performance and reducing namespace pollution:

Template.Reserved_SearchList = set(dir(Template))

You can then go back to using self.Reserved_SearchList, which should be
faster than a global lookup.  (I'm only mentioning this because you're
using the lookup in a loop.)
-- 
Aahz ([email protected])           <*>         http://www.pythoncraft.com/

"To me vi is Zen.  To use vi is to practice zen.  Every command is a
koan.  Profound to the user, unintelligible to the uninitiated.  You
discover truth everytime you use it."  [email protected]

------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay 
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference