Message38693
Logged In: YES
user_id=52562
Okay I've done some "mini benchmarks". The earlier reported
micro-benchmarks were the result of running the inner loop
itself, in C. These mini benchmarks are the result of
running this Python script:
class A:
def __init__(self):
self.a = 0
a = A()
for i in xrange(2**20):
a.a = i
print a.a
and then using different attribute names in place of `a'.
The results are as expected: the optimized version is faster
than the current one, depending on the shape of the
attribute name, and dampened by the fact that there is now
other work being done. The case that shows the smallest
difference is when the attribute name neither begins nor
ends with an '_'. In that case the above script runs about
2% faster with the optimizations. The case that shows the
biggest difference is when the attribute begins and ends
with '__', as in `__a__'. Then the above script runs about
15% faster.
This still isn't a *real* application benchmark. I'm
looking for one that is a reasonable case for real Python
users but that also uses attribute lookups heavily.
|
|
Date |
User |
Action |
Args |
2007-08-23 15:10:31 | admin | link | issue502415 messages |
2007-08-23 15:10:31 | admin | create | |
|