On 24 Mar 2007 13:08:02 -0700, 7stud <[EMAIL PROTECTED]> wrote: >On Mar 23, 4:04 pm, Jack Diederich <[EMAIL PROTECTED]> 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"] >
Only one list is created. It is used to define a C array where attributes will be stored. Each instance still has that C array, but it has much less overhead than a Python list or dictionary. Whether this reduction in overhead actually results in a useful or measurable performance improvement is a separate question, of course. Jean-Paul -- http://mail.python.org/mailman/listinfo/python-list