[Patches] [ python-Patches-423262 ] Change module attribute get & set
noreply@sourceforge.net
noreply@sourceforge.net
Fri, 11 May 2001 06:35:28 -0700
Patches item #423262, was updated on 2001-05-11 02:11
You can respond by visiting:
http://sourceforge.net/tracker/?func=detail&atid=305470&aid=423262&group_id=5470
Category: core (C code)
Group: None
Status: Open
Resolution: None
Priority: 5
Submitted By: Tim Peters (tim_one)
>Assigned to: Tim Peters (tim_one)
Summary: Change module attribute get & set
Initial Comment:
Module objects currently don't define the tp_getattro
or tp_setattro slots. As a result, interning of
attribute names does them no good: a char* is always
passed, so the dict lookup always needs to do a string
compare despite that the attribute name is interned.
The patch simply implements these slots, and nulls out
the raw-string tp_getattr and tp_setattr slots.
The former is by far the more important one, and I've
measured speedups over 25% for simple programs that do
lots of module lookups inside loops (random.random,
os.path, etc).
So, sure looks like a big cheap win to me, but
assigning for review in case I'm missing something
obvious (i.e., if it's such an easy win, why didn't we
already do it?).
----------------------------------------------------------------------
Comment By: Guido van Rossum (gvanrossum)
Date: 2001-05-11 06:35
Message:
Logged In: YES
user_id=6380
There's no deep reason -- this code is ancient and has never
drawn anybody's attention. I noticed the same thing while
doing a review of getattr vs. getattro for the descr-branch
code.
So I'd say, go for it!
----------------------------------------------------------------------
You can respond by visiting:
http://sourceforge.net/tracker/?func=detail&atid=305470&aid=423262&group_id=5470