Pablo Galindo Salgado <pablog...@gmail.com> added the comment:

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

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue42093>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to