[issue45829] Remove C stack use by specializing BINARY_SUBSCR, STORE_SUBSCR, LOAD_ATTR, and STORE_ATTR
Mark Shannon
report at bugs.python.org
Wed Nov 17 04:50:11 EST 2021
New submission from Mark Shannon <mark at hotpy.org>:
We can remove the C stack use and general overhead of calling special methods implemented in Python for attribute access and indexing.
Each operation has a special method that implements it. When that special method is implemented in Python, we should avoid the `tp_xxx` slot machinery and use the same mechanism we use for normal calls to Python functions.
* BINARY_SUBSCR: `__getitem__`
* STORE_SUBSCR: `__setitem__`
* LOAD_ATTR: `__getattribute__` (and maybe `__getattr__`)
* STORE_ATTR: `__setattr__`
It probably isn't worth bothering with the deletion forms.
The getters (`__getitem__` and `__getattribute__`) are relatively simple, as the call returns the result.
The setters are a bit more complicated as the return value needs to be discarded, so an additional frame which discards the result of the call needs to be inserted.
----------
assignee: Mark.Shannon
components: Interpreter Core
messages: 406461
nosy: Mark.Shannon, brandtbucher, pablogsal
priority: normal
severity: normal
status: open
title: Remove C stack use by specializing BINARY_SUBSCR, STORE_SUBSCR, LOAD_ATTR, and STORE_ATTR
type: performance
versions: Python 3.11
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue45829>
_______________________________________
More information about the Python-bugs-list
mailing list