Python object overhead?

7stud bbxx789_05ss at yahoo.com
Sat Mar 24 16:08:02 EDT 2007


On Mar 23, 4:04 pm, Jack Diederich <jackd... at jackdied.com> wrote:
>
> If you make the record a new style class (inherit from object) you can
> specify the __slots__ attribute on the class.  This eliminates the per
> instance dictionary overhead in exchange for less flexibility.
>

How is efficiency improved with __slots__?  Don't you create a list
object that replaces the dictionary object, e.g.:

class Test(object):
        __slots__ = ["m", "n"]





More information about the Python-list mailing list