-
-
Notifications
You must be signed in to change notification settings - Fork 32.4k
Open
Labels
3.15new features, bugs and security fixesnew features, bugs and security fixesperformancePerformance or resource usagePerformance or resource usage
Description
This function
def f(x, y, c):
return 1 + (x if c else y)
compiles to
1 RESUME 0
2 LOAD_SMALL_INT 1
LOAD_FAST_BORROW 2 (c)
TO_BOOL
POP_JUMP_IF_FALSE 9 (to L1)
NOT_TAKEN
LOAD_FAST_BORROW 0 (x)
BINARY_OP 0 (+)
RETURN_VALUE
L1: LOAD_FAST 1 (y)
BINARY_OP 0 (+)
RETURN_VALUE
Note that the load of y
uses LOAD_FAST
even though LOAD_FAST_BORROW
is safe.
This becomes important with virtual iterators as the iterable for the loop is live at BB end.
Linked PRs
Metadata
Metadata
Assignees
Labels
3.15new features, bugs and security fixesnew features, bugs and security fixesperformancePerformance or resource usagePerformance or resource usage