Message385922
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. |
|
Date |
User |
Action |
Args |
2021-01-29 17:31:14 | gvanrossum | set | recipients:
+ gvanrossum, barry, nascheme, methane, Mark.Shannon, yselivanov, Guido.van.Rossum, corona10, pablogsal, Johan Dahlin, BTaskaya, bismatrimony |
2021-01-29 17:31:14 | gvanrossum | set | messageid: <1611941474.91.0.431820946601.issue42115@roundup.psfhosted.org> |
2021-01-29 17:31:14 | gvanrossum | link | issue42115 messages |
2021-01-29 17:31:14 | gvanrossum | create | |
|