summaryrefslogtreecommitdiffstats
path: root/Python/opcode_metadata.h
diff options
context:
space:
mode:
authorCarl Meyer <carl@oddbird.net>2023-04-24 22:22:14 (GMT)
committerGitHub <noreply@github.com>2023-04-24 22:22:14 (GMT)
commit0dc8b50d33208e9ca4fc3d959c6798529731f020 (patch)
tree822102a5177183fc6ad7075bd74a02a5633edc52 /Python/opcode_metadata.h
parent22bed58e531ce780d91f3364c5ace98fad28c2e8 (diff)
downloadcpython-0dc8b50d33208e9ca4fc3d959c6798529731f020.zip
cpython-0dc8b50d33208e9ca4fc3d959c6798529731f020.tar.gz
cpython-0dc8b50d33208e9ca4fc3d959c6798529731f020.tar.bz2
gh-87729: add LOAD_SUPER_ATTR instruction for faster super() (#103497)
This speeds up `super()` (by around 85%, for a simple one-level `super().meth()` microbenchmark) by avoiding allocation of a new single-use `super()` object on each use.
Diffstat (limited to 'Python/opcode_metadata.h')
-rw-r--r--Python/opcode_metadata.h5
1 files changed, 5 insertions, 0 deletions
diff --git a/Python/opcode_metadata.h b/Python/opcode_metadata.h
index 4681ed0..fb370ef 100644
--- a/Python/opcode_metadata.h
+++ b/Python/opcode_metadata.h
@@ -205,6 +205,8 @@ _PyOpcode_num_popped(int opcode, int oparg, bool jump) {
return 1;
case MAP_ADD:
return 2;
+ case LOAD_SUPER_ATTR:
+ return 3;
case LOAD_ATTR:
return 1;
case LOAD_ATTR_INSTANCE_VALUE:
@@ -589,6 +591,8 @@ _PyOpcode_num_pushed(int opcode, int oparg, bool jump) {
return 0;
case MAP_ADD:
return 0;
+ case LOAD_SUPER_ATTR:
+ return ((oparg & 1) ? 1 : 0) + 1;
case LOAD_ATTR:
return ((oparg & 1) ? 1 : 0) + 1;
case LOAD_ATTR_INSTANCE_VALUE:
@@ -879,6 +883,7 @@ const struct opcode_metadata _PyOpcode_opcode_metadata[256] = {
[DICT_UPDATE] = { true, INSTR_FMT_IB },
[DICT_MERGE] = { true, INSTR_FMT_IB },
[MAP_ADD] = { true, INSTR_FMT_IB },
+ [LOAD_SUPER_ATTR] = { true, INSTR_FMT_IB },
[LOAD_ATTR] = { true, INSTR_FMT_IBC00000000 },
[LOAD_ATTR_INSTANCE_VALUE] = { true, INSTR_FMT_IBC00000000 },
[LOAD_ATTR_MODULE] = { true, INSTR_FMT_IBC00000000 },