[Python-Dev] nested scopes confusion (original) (raw)

Thomas Heller thomas.heller@ion-tof.com
Tue, 4 Dec 2001 21:28:17 +0100


But the performance characteristics of class vs. function is really the bottleneck of your application? Are you sure that nested fuctions are really cheaper? Is seems do.

Here's a simple test:

def Method(index): return lambda self, *args: index

class A: def test(self, *args): return 5

class C: test = Method(42)

a = A() c = C()

Calling a.test() takes 3.3 microseconds, and c.test() takes 3.16 microseconds.

Thomas