Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(22)

Side by Side Diff: Doc/library/dis.rst

Issue 27095: Simplify MAKE_FUNCTION
Patch Set: Created 3 years, 10 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | Include/opcode.h » ('j') | Lib/lib2to3/tests/data/py3_test_grammar.py » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 :mod:`dis` --- Disassembler for Python bytecode 1 :mod:`dis` --- Disassembler for Python bytecode
2 =============================================== 2 ===============================================
3 3
4 .. module:: dis 4 .. module:: dis
5 :synopsis: Disassembler for Python bytecode. 5 :synopsis: Disassembler for Python bytecode.
6 6
7 **Source code:** :source:`Lib/dis.py` 7 **Source code:** :source:`Lib/dis.py`
8 8
9 -------------- 9 --------------
10 10
(...skipping 910 matching lines...) Expand 10 before | Expand all | Expand 10 after
921 value is on top of the key. Below the keyword parameters, the positional 921 value is on top of the key. Below the keyword parameters, the positional
922 parameters are on the stack, with the right-most parameter on top. Below the 922 parameters are on the stack, with the right-most parameter on top. Below the
923 parameters, the function object to call is on the stack. Pops all function 923 parameters, the function object to call is on the stack. Pops all function
924 arguments, and the function itself off the stack, and pushes the return 924 arguments, and the function itself off the stack, and pushes the return
925 value. 925 value.
926 926
927 927
928 .. opcode:: MAKE_FUNCTION (argc) 928 .. opcode:: MAKE_FUNCTION (argc)
929 929
930 Pushes a new function object on the stack. From bottom to top, the consumed 930 Pushes a new function object on the stack. From bottom to top, the consumed
931 stack must consist of 931 stack must consist of values if the argument carries a specified flag value
932 932
933 * ``argc & 0xFF`` default argument objects in positional order 933 * ``0x01`` a tuple of default argument objects in positional order
934 * ``(argc >> 8) & 0xFF`` pairs of name and default argument, with the name 934 * ``0x02`` a dictionary of keyword-only parameters' default values
935 just below the object on the stack, for keyword-only parameters 935 * ``0x04`` an annotation dictionary
936 * ``(argc >> 16) & 0x7FFF`` parameter annotation objects 936 * ``0x08`` a tuple containing cells for free variables, making a closure
937 * a tuple listing the parameter names for the annotations (only if there are
938 ony annotation objects)
939 * the code associated with the function (at TOS1) 937 * the code associated with the function (at TOS1)
940 * the :term:`qualified name` of the function (at TOS) 938 * the :term:`qualified name` of the function (at TOS)
941
942
943 .. opcode:: MAKE_CLOSURE (argc)
944
945 Creates a new function object, sets its *__closure__* slot, and pushes it on
946 the stack. TOS is the :term:`qualified name` of the function, TOS1 is the
947 code associated with the function, and TOS2 is the tuple containing cells for
948 the closure's free variables. *argc* is interpreted as in ``MAKE_FUNCTION``;
949 the annotations and defaults are also in the same order below TOS2.
950 939
951 940
952 .. opcode:: BUILD_SLICE (argc) 941 .. opcode:: BUILD_SLICE (argc)
953 942
954 .. index:: builtin: slice 943 .. index:: builtin: slice
955 944
956 Pushes a slice object on the stack. *argc* must be 2 or 3. If it is 2, 945 Pushes a slice object on the stack. *argc* must be 2 or 3. If it is 2,
957 ``slice(TOS1, TOS)`` is pushed; if it is 3, ``slice(TOS2, TOS1, TOS)`` is 946 ``slice(TOS1, TOS)`` is pushed; if it is 3, ``slice(TOS2, TOS1, TOS)`` is
958 pushed. See the :func:`slice` built-in function for more information. 947 pushed. See the :func:`slice` built-in function for more information.
959 948
960 949
961 .. opcode:: EXTENDED_ARG (ext) 950 .. opcode:: EXTENDED_ARG (ext)
962 951
963 Prefixes any opcode which has an argument too big to fit into the default two 952 EXTENDED_ARG adds ``*ext* * 256`` to the next instruction's argument.
964 bytes. *ext* holds two additional bytes which, taken together with the 953 This is used for arguments exceeding a byte in size, and can be chained
965 subsequent opcode's argument, comprise a four-byte argument, *ext* being the 954 to create 4-byte arguments.
966 two most-significant bytes.
967 955
968 956
969 .. opcode:: CALL_FUNCTION_VAR (argc) 957 .. opcode:: CALL_FUNCTION_VAR (argc)
970 958
971 Calls a function. *argc* is interpreted as in :opcode:`CALL_FUNCTION`. The 959 Calls a function. *argc* is interpreted as in :opcode:`CALL_FUNCTION`. The
972 top element on the stack contains the variable argument list, followed by 960 top element on the stack contains the variable argument list, followed by
973 keyword and positional arguments. 961 keyword and positional arguments.
974 962
975 963
976 .. opcode:: CALL_FUNCTION_KW (argc) 964 .. opcode:: CALL_FUNCTION_KW (argc)
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
1068 1056
1069 1057
1070 .. data:: haslocal 1058 .. data:: haslocal
1071 1059
1072 Sequence of bytecodes that access a local variable. 1060 Sequence of bytecodes that access a local variable.
1073 1061
1074 1062
1075 .. data:: hascompare 1063 .. data:: hascompare
1076 1064
1077 Sequence of bytecodes of Boolean operations. 1065 Sequence of bytecodes of Boolean operations.
OLDNEW
« no previous file with comments | « no previous file | Include/opcode.h » ('j') | Lib/lib2to3/tests/data/py3_test_grammar.py » ('J')

RSS Feeds Recent Issues | This issue
This is Rietveld 894c83f36cb7+