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 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 <>
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

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

if meth_found:
    if <optimizing etc.>:
        lm = ...
        lm->type = type
        lm->meth = meth


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.
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: <>
2021-01-29 17:31:14gvanrossumlinkissue42115 messages
2021-01-29 17:31:14gvanrossumcreate