mirror of
https://github.com/python/cpython.git
synced 2025-08-22 17:55:18 +00:00
GH-100762: Don't call gen.throw()
in gen.close()
, unless necessary. (GH-101013)
* Store exception stack depth in YIELD_VALUE's oparg and use it avoid expensive gen.throw() in gen.close() where possible.
This commit is contained in:
parent
daec3a463c
commit
f02fa64bf2
9 changed files with 39 additions and 12 deletions
|
@ -7162,9 +7162,6 @@ stackdepth(basicblock *entryblock, int code_flags)
|
|||
next = NULL;
|
||||
break;
|
||||
}
|
||||
if (instr->i_opcode == YIELD_VALUE) {
|
||||
instr->i_oparg = depth;
|
||||
}
|
||||
}
|
||||
if (next != NULL) {
|
||||
assert(BB_HAS_FALLTHROUGH(b));
|
||||
|
@ -7332,6 +7329,9 @@ label_exception_targets(basicblock *entryblock) {
|
|||
}
|
||||
}
|
||||
else {
|
||||
if (instr->i_opcode == YIELD_VALUE) {
|
||||
instr->i_oparg = except_stack->depth;
|
||||
}
|
||||
instr->i_except = handler;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue