mirror of
https://github.com/python/cpython.git
synced 2025-08-03 08:34:29 +00:00
Merged revisions 72912,72920,72940 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk ........ r72912 | benjamin.peterson | 2009-05-25 08:13:44 -0500 (Mon, 25 May 2009) | 5 lines add a SETUP_WITH opcode It speeds up the with statement and correctly looks up the special methods involved. ........ r72920 | benjamin.peterson | 2009-05-25 15:12:57 -0500 (Mon, 25 May 2009) | 1 line take into account the fact that SETUP_WITH pushes a finally block ........ r72940 | benjamin.peterson | 2009-05-26 07:49:59 -0500 (Tue, 26 May 2009) | 1 line teach the peepholer about SETUP_WITH ........
This commit is contained in:
parent
d2397753ee
commit
876b2f286b
10 changed files with 105 additions and 84 deletions
|
@ -436,6 +436,18 @@ the stack so that it is available for further iterations of the loop.
|
|||
by ``CALL_FUNCTION`` to construct a class.
|
||||
|
||||
|
||||
.. opcode:: SETUP_WITH (delta)
|
||||
|
||||
This opcode performs several operations before a with block starts. First,
|
||||
it loads :meth:`~object.__exit__` from the context manager and pushes it onto
|
||||
the stack for later use by :opcode:`WITH_CLEANUP`. Then,
|
||||
:meth:`~object.__enter__` is called, and a finally block pointing to *delta*
|
||||
is pushed. Finally, the result of calling the enter method is pushed onto
|
||||
the stack. The next opcode will either ignore it (:opcode:`POP_TOP`), or
|
||||
store it in (a) variable(s) (:opcode:`STORE_FAST`, :opcode:`STORE_NAME`, or
|
||||
:opcode:`UNPACK_SEQUENCE`).
|
||||
|
||||
|
||||
.. opcode:: WITH_CLEANUP ()
|
||||
|
||||
Cleans up the stack when a :keyword:`with` statement block exits. TOS is
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue