A modest proposal (continued)

John Roth johnroth at ameritech.net
Fri Nov 16 00:49:33 EST 2001


Didn't we discuss this a month or two ago? There was
quite a bit of talk about speeding up access to module
level names and so forth, even going into the changes
needed in the bytecode set, and possibly even
an implementation.

John Roth

"Stuart D. Gathman" <stuart at bmsi.com> wrote in message
news:9t1uce$5d8$1 at nntp1-cm.news.eni.net...
> In article <7xu1vvo432.fsf at ruckus.brouhaha.com>, "Paul Rubin"
> <phr-n2001d at nightsong.com> wrote:
>
> > I think it's more important to optimize locals and class attribute
> > references (local.x.y.z), than globals.
>
> The SymbolTable/array separation optimizes class attributes.  You
missed
> that section in my first post, so I'll repeat it in different words
here.
>
> The SymbolTable is stored with the class - initialized to all class
> attributes mentioned in the code defined within the class.  The
attribute
> array is stored with each instance.  Dynamically adding attributes to
a
> class is handled by
>
> a) growing the class SYmbolTable and expanding instance attribute
arrays
> as needed.  This could result in lots of unused instance slots when
lots
> of random identifiers are added dynamically.
>
> b) keeping an auxilliary dictionary for attributes not mentioned in
the
> initial class definition.
>
> I guess the big problem is accounting for a class possibly overriding
> attribute fetching.  However, if we simply *always* call __getattr__,
and
> the default definition simply follows the same strategy as the load
global
> and is coded inline, then a class attribute lookup is essentially
> equivalent to two optimized globals.
>
> E.g.
>
>     load class idxOf__getattr__ # cached like global access if not
>     defined:
>       load class idxOfName    # cached like global access
>     else:
>       call __getattr__
>
> --
>       Stuart D. Gathman <stuart at bmsi.com>
> Business Management Systems Inc.  Phone: 703 591-0911 Fax: 703
591-6154
> "Confutatis maledictis, flamis acribus addictis" - background song for
> a Microsoft sponsored "Where do you want to go from here?" commercial.





More information about the Python-list mailing list