New submission from Jeffrey Yasskin: (On a MacBook Pro 2.33 GHz)
$ ./python.exe -m timeit -s 'class Foo(object): pass' -s 'f = Foo()' 'f.num = 3' 10000000 loops, best of 3: 0.13 usec per loop $ ./python.exe -m timeit -s 'class Foo(object): __slots__ = ["num"]' -s 'f = Foo()' 'f.num = 3' 1000000 loops, best of 3: 1.24 usec per loop Attribute reading isn't affected: $ ./python.exe -m timeit -s 'class Foo(object): pass' -s 'f = Foo(); f.num = 3' 'g = f.num' 10000000 loops, best of 3: 0.107 usec per loop $ ./python.exe -m timeit -s 'class Foo(object): __slots__ = ["num"]' -s 'f = Foo(); f.num = 3' 'g = f.num' 10000000 loops, best of 3: 0.101 usec per loop ---------- components: Interpreter Core messages: 62408 nosy: jyasskin severity: normal status: open title: __slots__ make attribute setting 10x slower type: resource usage versions: Python 2.6 __________________________________ Tracker <[EMAIL PROTECTED]> <http://bugs.python.org/issue2115> __________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com