Jack wrote: > People have illusion that it is faster to visit the attribute defined > by __slots__ . > http://groups.google.com/group/comp.lang.python/msg/c4e413c3d86d80be > > That is wrong. The following tests show it is slower.
Not so fast. Here's what I get (python2.6.4, 64 bit): $ python -mtimeit -s "class A(object): __slots__ = ('a', 'b', 'c')" -s "inst = A()" "inst.a=5; inst.b=6; inst.c=7" 1000000 loops, best of 3: 0.324 usec per loop $ python -mtimeit -s "class A(object): pass" -s "inst = A()" "inst.a=5; inst.b=6; inst.c=7" 1000000 loops, best of 3: 0.393 usec per loop Now what? -- http://mail.python.org/mailman/listinfo/python-list