STORE_FAST followed by LOAD_FAST of the same thing #388
iritkatriel
started this conversation in
Ideas
Replies: 3 comments 2 replies
-
Implemented in a branch so we can measure the impact: |
Beta Was this translation helpful? Give feedback.
0 replies
-
Hm... |
Beta Was this translation helpful? Give feedback.
1 reply
-
How would this affect line tracing? def f():
x = 10
y \
= \
x
def trace(frame, event, arg):
if event == "line":
print(frame.f_lineno)
print(frame.f_locals)
return trace
import sys
sys.settrace(trace)
f() Current result
A super-instruction might be another solution with different tradeoffs (less worry about tracing, a hair more code in the eval loop). |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I came across this sequence, where we store and then load the same thing:
it can be replaced by
COPY 1 is probably faster than LOAD_FAST.
I counted them with count_opcodes and it's not very rare - about 0.3% of the opcodes.
Beta Was this translation helpful? Give feedback.
All reactions