You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We would like try-except to run fastest when no exception is raised ('the happy path'). Currently the code is laid out such that in the happy path we need to jump over the except block (see faster-cpython/ideas#226).
We can avoid this jump if we place the except block at the end of the function's bytecode block. To do this, the compiler will detect "cold" basic blocks (those only reachable from exception targets) and reorder the blocks so that the cold blocks are at the end.
Example:
def f():
try:
x = "try"
except:
x = "except"
finally:
x = "finally"
return x
We would like try-except to run fastest when no exception is raised ('the happy path'). Currently the code is laid out such that in the happy path we need to jump over the except block (see faster-cpython/ideas#226).
We can avoid this jump if we place the except block at the end of the function's bytecode block. To do this, the compiler will detect "cold" basic blocks (those only reachable from exception targets) and reorder the blocks so that the cold blocks are at the end.
Example:
Becomes:
instead of:
The text was updated successfully, but these errors were encountered: