Author gvanrossum
Recipients BTaskaya, Guido.van.Rossum, Johan Dahlin, Mark.Shannon, barry, bismatrimony, corona10, gvanrossum, methane, nascheme, pablogsal, yselivanov
Date 2021-01-29.17:31:14
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1611941474.91.0.431820946601.issue42115@roundup.psfhosted.org>
In-reply-to
Content
I had a simpler idea for an inline cache for LOAD_METHOD than GH-23503. The essential part goes like this (sorry for the hybrid C/Python):

if <optimized etc.>:
    if type == lm->type and type->tp_version_tag == lm->tp_version_tag:
        meth = lm->meth
        SET_TOP(meth)
        PUSH(obj)
        DISPATCH()

name = GETITEM(names, oparg)
meth_found = _PyObject_GetMethod(obj, name, &meth)
<error check>

if meth_found:
    SET_TOP(meth)
    PUSH(obj)
    if <optimizing etc.>:
        lm = ...
        lm->type = type
        lm->meth = meth

<etc.>

What am I missing? Why is the hash of the name needed?


Oh, it's probably because there could still be an overriding value in obj.__dict__. But certainly we could check for type == lm->type before the other checks (HasFeature and tp_version_tag).

But what if we only did this for classes without an instance dict? That could work for things like list.append and str.find.
History
Date User Action Args
2021-01-29 17:31:14gvanrossumsetrecipients: + gvanrossum, barry, nascheme, methane, Mark.Shannon, yselivanov, Guido.van.Rossum, corona10, pablogsal, Johan Dahlin, BTaskaya, bismatrimony
2021-01-29 17:31:14gvanrossumsetmessageid: <1611941474.91.0.431820946601.issue42115@roundup.psfhosted.org>
2021-01-29 17:31:14gvanrossumlinkissue42115 messages
2021-01-29 17:31:14gvanrossumcreate