diff options
author | Nick Coghlan <ncoghlan@gmail.com> | 2008-03-07 14:13:28 (GMT) |
---|---|---|
committer | Nick Coghlan <ncoghlan@gmail.com> | 2008-03-07 14:13:28 (GMT) |
commit | 7af53be66f8c074902e0e7e7c452a280538582bc (patch) | |
tree | c2d5933745c44a5099ceadb4f81bc7aa82dfe1c1 /Doc | |
parent | e75f59a578a4538451c1d96610a6d183ba8f2e81 (diff) | |
download | cpython-7af53be66f8c074902e0e7e7c452a280538582bc.zip cpython-7af53be66f8c074902e0e7e7c452a280538582bc.tar.gz cpython-7af53be66f8c074902e0e7e7c452a280538582bc.tar.bz2 |
Speed up with statements by storing the __exit__ method on the stack instead of in a temp variable (bumps the magic number for pyc files)
Diffstat (limited to 'Doc')
-rw-r--r-- | Doc/library/dis.rst | 27 |
1 files changed, 15 insertions, 12 deletions
diff --git a/Doc/library/dis.rst b/Doc/library/dis.rst index c03feb7..d83ac3d 100644 --- a/Doc/library/dis.rst +++ b/Doc/library/dis.rst @@ -519,21 +519,24 @@ Miscellaneous opcodes. .. opcode:: WITH_CLEANUP () - Cleans up the stack when a :keyword:`with` statement block exits. TOS is the - context manager's :meth:`__exit__` bound method. Below that are 1--3 values - indicating how/why the finally clause was entered: + Cleans up the stack when a :keyword:`with` statement block exits. On top of + the stack are 1--3 values indicating how/why the finally clause was entered: - * SECOND = ``None`` - * (SECOND, THIRD) = (``WHY_{RETURN,CONTINUE}``), retval - * SECOND = ``WHY_*``; no retval below it - * (SECOND, THIRD, FOURTH) = exc_info() + * TOP = ``None`` + * (TOP, SECOND) = (``WHY_{RETURN,CONTINUE}``), retval + * TOP = ``WHY_*``; no retval below it + * (TOP, SECOND, THIRD) = exc_info() - In the last case, ``TOS(SECOND, THIRD, FOURTH)`` is called, otherwise - ``TOS(None, None, None)``. + Under them is EXIT, the context manager's :meth:`__exit__` bound method. - In addition, if the stack represents an exception, *and* the function call - returns a 'true' value, this information is "zapped", to prevent ``END_FINALLY`` - from re-raising the exception. (But non-local gotos should still be resumed.) + In the last case, ``EXIT(TOP, SECOND, THIRD)`` is called, otherwise + ``EXIT(None, None, None)``. + + EXIT is removed from the stack, leaving the values above it in the same + order. In addition, if the stack represents an exception, *and* the function + call returns a 'true' value, this information is "zapped", to prevent + ``END_FINALLY`` from re-raising the exception. (But non-local gotos should + still be resumed.) .. XXX explain the WHY stuff! |