Re: Costly object creation (was : Having Trouble with Scoping Rules)
- From: Charles Krug <cdkrug@xxxxxxx>
- Date: Tue, 31 Jan 2006 07:15:42 -0600
On 2006-01-31, bruno at modulix <onurb@xxxxxxxxxxx> wrote:
> See other answers in this thread for how to solve the UnboundLocalError
> problem.
>
> Now about your *real* problem - which is nothing new -, you may want to
> read about some known solutions:
>
> http://en.wikipedia.org/wiki/Singleton_pattern
> http://en.wikipedia.org/wiki/Proxy_pattern
> http://en.wikipedia.org/wiki/Lazy_initialization
> http://en.wikipedia.org/wiki/Memoization
>
No, I'm already quite certain that this is a Singleton--pythonically a
module-level instance of Something--I'm not thinking of it as "lazy
instantiated" 'cuz it's initialized at startup, but I suppose it
qualifies.
I considered using a Borg for this, but discarded the idea as "too
complicated for my needs--this will be easier to implement . . . "
Which I suppose it would be if I knew how correctly to use the "global"
keyword.
I don't need to restrict the actual class to One Instance so much as I'd
prefer that to be the default behavior. I can't think of a reason why
I'd want to subclass this, so I can't say whether it makes sense to
Borg/Highlander/Singleton it or not. For now, I'll Do The Simplest
Thing That Might Work and figure YAGNI (or IAGNI, I guess).
Thanks for the help.
.
- References:
- Having Trouble with Scoping Rules
- From: Charles Krug
- Re: Costly object creation (was : Having Trouble with Scoping Rules)
- From: bruno at modulix
- Having Trouble with Scoping Rules
- Prev by Date: Introspection with classes
- Next by Date: Re: Help with XML-SAX program ... it's driving me nuts ...
- Previous by thread: Re: Costly object creation (was : Having Trouble with Scoping Rules)
- Next by thread: ANN: Rur-ple 0.95 has been released
- Index(es):
Relevant Pages
|