Singleton class: what is the purpose?

Nielson Family junk at geekabytes.net
Fri Jun 6 17:02:31 EDT 2003


Simon Burton wrote:

>On Fri, 06 Jun 2003 01:49:42 +0000, Gordon Scott wrote:
>
>  
>
>>Is there any difference between the Borg and the Flyweight?  Sound like the
>>same thing.
>>
>>Gordo
>>
>>    
>>
>
>My take:
>
>A Flyweight would be an instance shared, where there are many flyweights.
>If there is only one flyweight then it's a singleton.
>
>ints (and the other immutables) are flyweights in python.
>
>Simon Burton.
>
>
>
>  
>
I've found your discussion of patterns quite interesting.

 From what I understand of the Flyweight pattern, it and the singleton 
pattern are different in the underlying strucutre.

I'm not sure it's accurate to say that one flyweight= singleton, though 
it's possible that a singleton might be used _as_ a flyweight.  In other 
words, a flyweight could also be a singleton, but it is not necessarily 
so, and a singleton could function as a flyweight, but a singleton is 
not, by definition a single flyweight.

-- Seth James Nielson






More information about the Python-list mailing list