This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author zooko
Recipients
Date 2002-01-11.18:07:41
SpamBayes Score
Marked as misclassified
Message-id
In-reply-to
Content
This patch optimizes the string comparisons in
class_getattr(), class_setattr(), instance_getattr1(),
and instance_setattr().

I pulled out the relevant section of class_setattr()
and measured its performance, yielding the following
results:

 * in the case that the argument does *not* begin with
"__", then the new version is 1.03 times as fast as the
old.  (This is a mystery to me, as the path through the
code looks the same, in C.  I examined the assembly
that GCC v3.0.3 generated in -O3 mode, and it is true
that the assembly for the new version is
smaller/faster, although I don't really understand why.)

 * in the case that the argument is a string of random
length between 1 and 19 inclusive, and it begins with
"__" and ends with "X_" (where X is a random alphabetic
character), then the new version 1.12 times as fast as
the old.

 * in the case that the argument is a string of random
length between 1 and 19 inclusive, and it begins with
"__" and does *not* end with "_", then the new version
1.16 times as fast as the old.

 * in the case that the argument is (randomly) one of
the six special names, then the new version is 2.7
times as fast as the old.

 * in the case that the argument is a string of random
length between 1 and 19 inclusive, and it begins with
"__" and ends with "__" (but is not one of the six
special names), then the new version is 3.7 times as
fast as the old.

History
Date User Action Args
2007-08-23 15:10:30adminlinkissue502415 messages
2007-08-23 15:10:30admincreate