Message384364
| Author |
pablogsal |
| Recipients |
Guido.van.Rossum, gvanrossum, pablogsal, yselivanov |
| Date |
2021年01月05日.02:19:53 |
| SpamBayes Score |
-1.0 |
| Marked as misclassified |
Yes |
| Message-id |
<1609813194.07.0.457129178836.issue42093@roundup.psfhosted.org> |
| In-reply-to |
| Content |
> Thanks! Do you have any plans for further inline caches?
Yeah, we are experimenting with some ideas here: https://bugs.python.org/issue42115.
> I was wondering if we could reverse the situation for slots again by adding slots support to the LOAD_ATTR opcode inline cache...
I think we can do it as long as we can detect easily if a given descriptor is immutable. The problem of mutability is this code:
class Descriptor:
pass
class C:
def __init__(self):
self.x = 1
x = Descriptor()
def f(o):
return o.x
o = C()
for i in range(10000):
assert f(o) == 1
Descriptor.__get__ = lambda self, instance, value: 2
Descriptor.__set__ = lambda *args: None
print(f(o))
In this case, if we do not skip the cache for mutable descriptors, the code will not reflect the new result (2 instead of 1). __slots__ are immutable descriptors so we should be good as long as we can detect them. |
|
History
|
|---|
| Date |
User |
Action |
Args |
| 2021年01月05日 02:19:54 | pablogsal | set | recipients:
+ pablogsal, gvanrossum, yselivanov, Guido.van.Rossum |
| 2021年01月05日 02:19:54 | pablogsal | set | messageid: <1609813194.07.0.457129178836.issue42093@roundup.psfhosted.org> |
| 2021年01月05日 02:19:54 | pablogsal | link | issue42093 messages |
| 2021年01月05日 02:19:53 | pablogsal | create |
|