ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> wxpython-users
wxpython-users
Re: [wxpython-users] Simple scope question
by Timothy Grant other posts by this author
Jul 8 2008 4:28PM messages near this date
Re: [wxpython-users] Simple scope question | Re: [wxpython-users] Simple scope question
On Tue, Jul 8, 2008 at 3:45 PM, Phil Mayes <olivebr@[...].com>  wrote:

>   At 02:16 PM 7/8/2008, you wrote:
> 
>  I tried to reflect on what Chris wrote: being this one a matter of economy,
>  it should be possible to calculate it, more or less accurately.
> 
>  Every window in a class has a name, even if sometimes it is the default
>  name, and it has to be stored somewhere in memory. So to assign a specific
>  name to a control doesn't unduly impinge on memory (unless we call our
>  control Mr. Hasdrubal B. Weatherington Sr., Esq.).
> 
>  But even the programmer's time has its tiny value, and to write 400 times
>  in an application
>            self.FindWindowByName('grid')
>   is more boring than
>            self.grid
>  while the cost for this leisure is the addition of the variable name to the
>  memory: och aye, lads, with nowadays PCs I gather we can afford it.
> 
>  My only suggestion for the sanity of your mind, if you have more than a
>  couple of these variables in your class, is not to declare them in __init__
>  , where they would get mixed up with a lot of other code, but write a sort
>  of table at the beginning of the class, like:
>            grid = None
>            text = None
>            combo = None
> 
> 
>  I worry more about performance than memory.  It seems to me
>  that
>      self.FindWindowByname(name)
>  must execute way slower than
>      self.grid
> 

That would be my concern too. I believe I've read, but have not done a study
on the subject, that function/method calls are relatively expensive in
Python.

I'm not sure how one quantifies "relatively expensive" but I'll take the
dictionary lookup in this case.

-- 
Stand Fast,
tjg.
Thread:
John Dann
Raffaello
Phil Mayes
Robin Dunn
Raffaello
Robin Dunn
Timothy Grant
Josiah Carlson
Christopher Barker
Raffaello
Kyle W Rickey

Privacy Policy | Email Opt-out | Feedback | Syndication
© 2004 ActiveState, a division of Sophos All rights reserved