Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
dff21a6b
Commit
dff21a6b
authored
Apr 03, 1998
by
Fred Drake
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Minor nits.
Indent code sample to use 4-space indents.
parent
16a19c46
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
30 additions
and
34 deletions
+30
-34
Doc/lib/libdis.tex
Doc/lib/libdis.tex
+15
-17
Doc/libdis.tex
Doc/libdis.tex
+15
-17
No files found.
Doc/lib/libdis.tex
View file @
dff21a6b
\section
{
Standard Module
\
sectcod
e
{
dis
}}
\section
{
Standard Module
\
modul
e
{
dis
}}
\stmodindex
{
dis
}
\label
{
module-dis
}
The
\
cod
e
{
dis
}
module supports the analysis of Python byte code by
The
\
modul
e
{
dis
}
module supports the analysis of Python byte code by
disassembling it. Since there is no Python assembler, this module
defines the Python assembly language. The Python byte code which
this module takes as an input is defined in the file
\file
{
Include/opcode.h
}
and used by the compiler and the interpreter.
Example: Given the function
myfunc
Example: Given the function
\function
{
myfunc
}
:
\begin{verbatim}
def myfunc(alist):
return len(alist)
\end{verbatim}
the following command can be used to get the disassembly of
\code
{
myfunc()
}
:
the following command can be used to get the disassembly of
\function
{
myfunc()
}
:
\begin{verbatim}
>>> dis.dis(myfunc)
...
...
@@ -31,9 +31,7 @@ the following command can be used to get the disassembly of \code{myfunc()}:
19 RETURN
_
VALUE
\end{verbatim}
The
\code
{
dis
}
module defines the following functions:
\setindexsubitem
{
(in module dis)
}
The
\module
{
dis
}
module defines the following functions:
\begin{funcdesc}
{
dis
}{
\optional
{
bytesource
}}
Disassemble the
\var
{
bytesource
}
object.
\var
{
bytesource
}
can denote
...
...
@@ -53,8 +51,8 @@ is indicated.
Disassembles a code object, indicating the last instruction if
\var
{
lasti
}
was provided. The output is divided in the following columns:
\begin{itemize}
\item
the current instruction, indicated as
\
code
{
-->
}
,
\item
a labelled instruction, indicated with
\
code
{
>>
}
,
\item
the current instruction, indicated as
\
samp
{
-->
}
,
\item
a labelled instruction, indicated with
\
samp
{
>>
}
,
\item
the address of the instruction,
\item
the operation code name,
\item
operation parameters, and
...
...
@@ -324,14 +322,14 @@ bytes, with the more significant byte last.
\begin{opcodedesc}
{
STORE
_
NAME
}{
namei
}
Implements
\code
{
name = TOS
}
.
\var
{
namei
}
is the index of
\var
{
name
}
in the attribute
\
code
{
co
_
names
}
of the code object.
in the attribute
\
member
{
co
_
names
}
of the code object.
The compiler tries to use
\code
{
STORE
_
LOCAL
}
or
\code
{
STORE
_
GLOBAL
}
if possible.
\end{opcodedesc}
\begin{opcodedesc}
{
DELETE
_
NAME
}{
namei
}
Implements
\code
{
del name
}
, where
\var
{
namei
}
is the index into
\
code
{
co
_
names
}
attribute of the code object.
\
member
{
co
_
names
}
attribute of the code object.
\end{opcodedesc}
\begin{opcodedesc}
{
UNPACK
_
TUPLE
}{
count
}
...
...
@@ -349,12 +347,12 @@ Unpacks TOS into \var{count} individual values.
\begin{opcodedesc}
{
STORE
_
ATTR
}{
namei
}
Implements
\code
{
TOS.name = TOS1
}
, where
\var
{
namei
}
is the index
of name in
\
code
{
co
_
names
}
.
of name in
\
member
{
co
_
names
}
.
\end{opcodedesc}
\begin{opcodedesc}
{
DELETE
_
ATTR
}{
namei
}
Implements
\code
{
del TOS.name
}
, using
\var
{
namei
}
as index into
\
code
{
co
_
names
}
.
\
member
{
co
_
names
}
.
\end{opcodedesc}
\begin{opcodedesc}
{
STORE
_
GLOBAL
}{
namei
}
...
...
@@ -370,11 +368,11 @@ Works as \code{DELETE_NAME}, but deletes a global name.
%\end{opcodedesc}
\begin{opcodedesc}
{
LOAD
_
CONST
}{
consti
}
Pushes
\
code
{
co
_
consts[
\var
{
consti
}
]
}
onto the stack.
Pushes
\
samp
{
co
_
consts[
\var
{
consti
}
]
}
onto the stack.
\end{opcodedesc}
\begin{opcodedesc}
{
LOAD
_
NAME
}{
namei
}
Pushes the value associated with
\
code
{
co
_
names[
\var
{
namei
}
]
}
onto the stack.
Pushes the value associated with
\
samp
{
co
_
names[
\var
{
namei
}
]
}
onto the stack.
\end{opcodedesc}
\begin{opcodedesc}
{
BUILD
_
TUPLE
}{
count
}
...
...
Doc/libdis.tex
View file @
dff21a6b
\section
{
Standard Module
\
sectcod
e
{
dis
}}
\section
{
Standard Module
\
modul
e
{
dis
}}
\stmodindex
{
dis
}
\label
{
module-dis
}
The
\
cod
e
{
dis
}
module supports the analysis of Python byte code by
The
\
modul
e
{
dis
}
module supports the analysis of Python byte code by
disassembling it. Since there is no Python assembler, this module
defines the Python assembly language. The Python byte code which
this module takes as an input is defined in the file
\file
{
Include/opcode.h
}
and used by the compiler and the interpreter.
Example: Given the function
myfunc
Example: Given the function
\function
{
myfunc
}
:
\begin{verbatim}
def myfunc(alist):
return len(alist)
\end{verbatim}
the following command can be used to get the disassembly of
\code
{
myfunc()
}
:
the following command can be used to get the disassembly of
\function
{
myfunc()
}
:
\begin{verbatim}
>>> dis.dis(myfunc)
...
...
@@ -31,9 +31,7 @@ the following command can be used to get the disassembly of \code{myfunc()}:
19 RETURN
_
VALUE
\end{verbatim}
The
\code
{
dis
}
module defines the following functions:
\setindexsubitem
{
(in module dis)
}
The
\module
{
dis
}
module defines the following functions:
\begin{funcdesc}
{
dis
}{
\optional
{
bytesource
}}
Disassemble the
\var
{
bytesource
}
object.
\var
{
bytesource
}
can denote
...
...
@@ -53,8 +51,8 @@ is indicated.
Disassembles a code object, indicating the last instruction if
\var
{
lasti
}
was provided. The output is divided in the following columns:
\begin{itemize}
\item
the current instruction, indicated as
\
code
{
-->
}
,
\item
a labelled instruction, indicated with
\
code
{
>>
}
,
\item
the current instruction, indicated as
\
samp
{
-->
}
,
\item
a labelled instruction, indicated with
\
samp
{
>>
}
,
\item
the address of the instruction,
\item
the operation code name,
\item
operation parameters, and
...
...
@@ -324,14 +322,14 @@ bytes, with the more significant byte last.
\begin{opcodedesc}
{
STORE
_
NAME
}{
namei
}
Implements
\code
{
name = TOS
}
.
\var
{
namei
}
is the index of
\var
{
name
}
in the attribute
\
code
{
co
_
names
}
of the code object.
in the attribute
\
member
{
co
_
names
}
of the code object.
The compiler tries to use
\code
{
STORE
_
LOCAL
}
or
\code
{
STORE
_
GLOBAL
}
if possible.
\end{opcodedesc}
\begin{opcodedesc}
{
DELETE
_
NAME
}{
namei
}
Implements
\code
{
del name
}
, where
\var
{
namei
}
is the index into
\
code
{
co
_
names
}
attribute of the code object.
\
member
{
co
_
names
}
attribute of the code object.
\end{opcodedesc}
\begin{opcodedesc}
{
UNPACK
_
TUPLE
}{
count
}
...
...
@@ -349,12 +347,12 @@ Unpacks TOS into \var{count} individual values.
\begin{opcodedesc}
{
STORE
_
ATTR
}{
namei
}
Implements
\code
{
TOS.name = TOS1
}
, where
\var
{
namei
}
is the index
of name in
\
code
{
co
_
names
}
.
of name in
\
member
{
co
_
names
}
.
\end{opcodedesc}
\begin{opcodedesc}
{
DELETE
_
ATTR
}{
namei
}
Implements
\code
{
del TOS.name
}
, using
\var
{
namei
}
as index into
\
code
{
co
_
names
}
.
\
member
{
co
_
names
}
.
\end{opcodedesc}
\begin{opcodedesc}
{
STORE
_
GLOBAL
}{
namei
}
...
...
@@ -370,11 +368,11 @@ Works as \code{DELETE_NAME}, but deletes a global name.
%\end{opcodedesc}
\begin{opcodedesc}
{
LOAD
_
CONST
}{
consti
}
Pushes
\
code
{
co
_
consts[
\var
{
consti
}
]
}
onto the stack.
Pushes
\
samp
{
co
_
consts[
\var
{
consti
}
]
}
onto the stack.
\end{opcodedesc}
\begin{opcodedesc}
{
LOAD
_
NAME
}{
namei
}
Pushes the value associated with
\
code
{
co
_
names[
\var
{
namei
}
]
}
onto the stack.
Pushes the value associated with
\
samp
{
co
_
names[
\var
{
namei
}
]
}
onto the stack.
\end{opcodedesc}
\begin{opcodedesc}
{
BUILD
_
TUPLE
}{
count
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment