[BangPypers] what is __slots__

Sibtey sibteym at infotechsw.com
Wed Feb 11 10:48:22 CET 2009


__slots__ is generally used for the memory optimization , suppose you are 
creating the 100 objects of a class then each instance of that class contain 
the __dict__.
As you know that __dict__  holds all the attributes of a class per instance 
basis, so __slots__ is a way to avoiding the creation of a dictionary 
__dict__,
add all the attributes of a class into the __slots__ something like
class A(object):
__slots__["a1","a2",............]
    def __ini__(self):pass

Sibtey mehdi



----- Original Message ----- 
From: "Parthan SR" <parth.technofreak at gmail.com>
To: "Bangalore Python Users Group - India" <bangpypers at python.org>
Sent: Wednesday, February 11, 2009 2:43 PM
Subject: Re: [BangPypers] what is __slots__


>M Kumar wrote:
>> how __slots__ can be useful for a python programmer, those who have time 
>> and consideration can help me out.
> This reminds me of this - 
> http://groups.google.com/group/comp.lang.python/msg/0f2e859b9c002b28
>
> -- 
> With Regards,
>
> Parthan "technofreak" (2FF01026)
> http://technofreak.in
>
> _______________________________________________
> BangPypers mailing list
> BangPypers at python.org
> http://mail.python.org/mailman/listinfo/bangpypers 



More information about the BangPypers mailing list