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

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

Issue 27095: Simplify MAKE_FUNCTION
Patch Set: Created 3 years, 4 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') | no next file with comments »
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 919 matching lines...) Expand 10 before | Expand all | Expand 10 after
930 value is on top of the key. Below the keyword parameters, the positional 930 value is on top of the key. Below the keyword parameters, the positional
931 parameters are on the stack, with the right-most parameter on top. Below the 931 parameters are on the stack, with the right-most parameter on top. Below the
932 parameters, the function object to call is on the stack. Pops all function 932 parameters, the function object to call is on the stack. Pops all function
933 arguments, and the function itself off the stack, and pushes the return 933 arguments, and the function itself off the stack, and pushes the return
934 value. 934 value.
935 935
936 936
937 .. opcode:: MAKE_FUNCTION (argc) 937 .. opcode:: MAKE_FUNCTION (argc)
938 938
939 Pushes a new function object on the stack. From bottom to top, the consumed 939 Pushes a new function object on the stack. From bottom to top, the consumed
940 stack must consist of 940 stack must consist of values if the argument carries a specified flag value
941 941
942 * ``argc & 0xFF`` default argument objects in positional order 942 * ``0x01`` a tuple of default argument objects in positional order
943 * ``(argc >> 8) & 0xFF`` pairs of name and default argument, with the name 943 * ``0x02`` a dictionary of keyword-only parameters' default values
944 just below the object on the stack, for keyword-only parameters 944 * ``0x04`` an annotation dictionary
945 * ``(argc >> 16) & 0x7FFF`` parameter annotation objects 945 * ``0x08`` a tuple containing cells for free variables, making a closure
946 * a tuple listing the parameter names for the annotations (only if there are
947 ony annotation objects)
948 * the code associated with the function (at TOS1) 946 * the code associated with the function (at TOS1)
949 * the :term:`qualified name` of the function (at TOS) 947 * the :term:`qualified name` of the function (at TOS)
950
951
952 .. opcode:: MAKE_CLOSURE (argc)
953
954 Creates a new function object, sets its *__closure__* slot, and pushes it on
955 the stack. TOS is the :term:`qualified name` of the function, TOS1 is the
956 code associated with the function, and TOS2 is the tuple containing cells for
957 the closure's free variables. *argc* is interpreted as in ``MAKE_FUNCTION``;
958 the annotations and defaults are also in the same order below TOS2.
959 948
960 949
961 .. opcode:: BUILD_SLICE (argc) 950 .. opcode:: BUILD_SLICE (argc)
962 951
963 .. index:: builtin: slice 952 .. index:: builtin: slice
964 953
965 Pushes a slice object on the stack. *argc* must be 2 or 3. If it is 2, 954 Pushes a slice object on the stack. *argc* must be 2 or 3. If it is 2,
966 ``slice(TOS1, TOS)`` is pushed; if it is 3, ``slice(TOS2, TOS1, TOS)`` is 955 ``slice(TOS1, TOS)`` is pushed; if it is 3, ``slice(TOS2, TOS1, TOS)`` is
967 pushed. See the :func:`slice` built-in function for more information. 956 pushed. See the :func:`slice` built-in function for more information.
968 957
969 958
970 .. opcode:: EXTENDED_ARG (ext) 959 .. opcode:: EXTENDED_ARG (ext)
971 960
972 Prefixes any opcode which has an argument too big to fit into the default two 961 EXTENDED_ARG adds ``*ext* * 256`` to the next instruction's argument.
storchaka 2016/06/12 16:36:42 I would prefer to commit this in issue26647 togeth
973 bytes. *ext* holds two additional bytes which, taken together with the 962 This is used for arguments exceeding a byte in size, and can be chained
974 subsequent opcode's argument, comprise a four-byte argument, *ext* being the 963 to create 4-byte arguments.
975 two most-significant bytes.
976 964
977 965
978 .. opcode:: CALL_FUNCTION_VAR (argc) 966 .. opcode:: CALL_FUNCTION_VAR (argc)
979 967
980 Calls a function. *argc* is interpreted as in :opcode:`CALL_FUNCTION`. The 968 Calls a function. *argc* is interpreted as in :opcode:`CALL_FUNCTION`. The
981 top element on the stack contains the variable argument list, followed by 969 top element on the stack contains the variable argument list, followed by
982 keyword and positional arguments. 970 keyword and positional arguments.
983 971
984 972
985 .. opcode:: CALL_FUNCTION_KW (argc) 973 .. opcode:: CALL_FUNCTION_KW (argc)
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
1077 1065
1078 1066
1079 .. data:: haslocal 1067 .. data:: haslocal
1080 1068
1081 Sequence of bytecodes that access a local variable. 1069 Sequence of bytecodes that access a local variable.
1082 1070
1083 1071
1084 .. data:: hascompare 1072 .. data:: hascompare
1085 1073
1086 Sequence of bytecodes of Boolean operations. 1074 Sequence of bytecodes of Boolean operations.
OLDNEW
« no previous file with comments | « no previous file | Include/opcode.h » ('j') | no next file with comments »

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