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
f7dd11fa
Commit
f7dd11fa
authored
Aug 24, 2000
by
Thomas Wouters
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rough and incomplete documentation on augmented assignment, which follows
shortly. Markup also needs checking.
parent
67582257
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
70 additions
and
4 deletions
+70
-4
Doc/lib/libdis.tex
Doc/lib/libdis.tex
+59
-0
Doc/ref/ref2.tex
Doc/ref/ref2.tex
+4
-0
Doc/ref/ref3.tex
Doc/ref/ref3.tex
+7
-4
No files found.
Doc/lib/libdis.tex
View file @
f7dd11fa
...
...
@@ -130,6 +130,11 @@ Lifts second and third stack item one position up, moves top down
to position three.
\end{opcodedesc}
\begin{opcodedesc}
{
ROT
_
FOUR
}{}
Lifts second, third and forth stack item one position up, moves top down to
position four.
\end{opcodedesc}
\begin{opcodedesc}
{
DUP
_
TOP
}{}
Duplicates the reference on top of the stack.
\end{opcodedesc}
...
...
@@ -209,6 +214,55 @@ Implements \code{TOS = TOS1 \^\ TOS}.
Implements
\code
{
TOS = TOS1 | TOS
}
.
\end{opcodedesc}
In-place operations are like binary operations, in that they remove TOS and
TOS1, and push the result back on the stack, but the operation is done
in-place when TOS1 supports it, and the resulting TOS may be (but does not
have to be) the original TOS1.
\begin{opcodedesc}
{
INPLACE
_
POWER
}{}
Implements in-place
\code
{
TOS = TOS1 ** TOS
}
.
\end{opcodedesc}
\begin{opcodedesc}
{
INPLACE
_
MULTIPLY
}{}
Implements in-place
\code
{
TOS = TOS1 * TOS
}
.
\end{opcodedesc}
\begin{opcodedesc}
{
INPLACE
_
DIVIDE
}{}
Implements in-place
\code
{
TOS = TOS1 / TOS
}
.
\end{opcodedesc}
\begin{opcodedesc}
{
INPLACE
_
MODULO
}{}
Implements in-place
\code
{
TOS = TOS1
\%
{}
TOS
}
.
\end{opcodedesc}
\begin{opcodedesc}
{
INPLACE
_
ADD
}{}
Implements in-place
\code
{
TOS = TOS1 + TOS
}
.
\end{opcodedesc}
\begin{opcodedesc}
{
INPLACE
_
SUBTRACT
}{}
Implements in-place
\code
{
TOS = TOS1 - TOS
}
.
\end{opcodedesc}
\begin{opcodedesc}
{
INPLACE
_
LSHIFT
}{}
Implements in-place
\code
{
TOS = TOS1 << TOS
}
.
\end{opcodedesc}
\begin{opcodedesc}
{
INPLACE
_
RSHIFT
}{}
Implements in-place
\code
{
TOS = TOS1 >> TOS
}
.
\end{opcodedesc}
\begin{opcodedesc}
{
INPLACE
_
AND
}{}
Implements in-place
\code
{
TOS = TOS1
\&\
TOS
}
.
\end{opcodedesc}
\begin{opcodedesc}
{
INPLACE
_
XOR
}{}
Implements in-place
\code
{
TOS = TOS1
\^\
TOS
}
.
\end{opcodedesc}
\begin{opcodedesc}
{
INPLACE
_
OR
}{}
Implements in-place
\code
{
TOS = TOS1 | TOS
}
.
\end{opcodedesc}
The slice opcodes take up to three parameters.
\begin{opcodedesc}
{
SLICE+0
}{}
...
...
@@ -366,6 +420,11 @@ the stack right-to-left.
%This opcode is obsolete.
%\end{opcodedesc}
\begin{opcodedesc}
{
DUP
_
TOPX
}{
count
}
Duplicate
\var
{
count
}
items, keeping them in the same order. Due to
implementation limits,
\var
{
count
}
should be between 1 and 5 inclusive.
\end{opcodedesc}
\begin{opcodedesc}
{
STORE
_
ATTR
}{
namei
}
Implements
\code
{
TOS.name = TOS1
}
, where
\var
{
namei
}
is the index
of name in
\member
{
co
_
names
}
.
...
...
Doc/ref/ref2.tex
View file @
f7dd11fa
...
...
@@ -523,10 +523,14 @@ The following tokens serve as delimiters in the grammar:
\begin{verbatim}
( ) [ ]
{
}
, : . ` = ;
+= -= *= /=
%= **=
&
= |=
^
= >>= <<=
\end{verbatim}
The period can also occur in floating-point and imaginary literals. A
sequence of three periods has a special meaning as an ellipsis in slices.
The second half of the list, the augmented assignment operators, serve
lexically as delimiters, but also perform an operation.
The following printing ASCII characters have special meaning as part
of other tokens or are otherwise significant to the lexical analyzer:
...
...
Doc/ref/ref3.tex
View file @
f7dd11fa
...
...
@@ -1054,9 +1054,10 @@ methods \method{append()}, \method{count()}, \method{index()},
and
\method
{
sort()
}
, like Python standard list objects. Finally,
sequence types should implement addition (meaning concatenation) and
multiplication (meaning repetition) by defining the methods
\method
{__
add
__
()
}
,
\method
{__
radd
__
()
}
,
\method
{__
mul
__
()
}
and
\method
{__
rmul
__
()
}
described below; they should not define
\method
{__
coerce
__
()
}
or other numerical operators.
\method
{__
add
__
()
}
,
\method
{__
radd
__
()
}
,
\method
{__
iadd
__
()
}
,
\method
{__
mul
__
()
}
,
\method
{__
rmul
__
()
}
and
\method
{__
imul
__
()
}
described
below; they should not define
\method
{__
coerce
__
()
}
or other numerical
operators.
\withsubitem
{
(mapping object method)
}{
\ttindex
{
keys()
}
\ttindex
{
values()
}
...
...
@@ -1077,8 +1078,10 @@ multiplication (meaning repetition) by defining the methods
\ttindex
{
sort()
}
\ttindex
{__
add
__
()
}
\ttindex
{__
radd
__
()
}
\ttindex
{__
iadd
__
()
}
\ttindex
{__
mul
__
()
}
\ttindex
{__
rmul
__
()
}}
\ttindex
{__
rmul
__
()
}
\ttindex
{__
imul
__
()
}}
\withsubitem
{
(numeric object method)
}{
\ttindex
{__
coerce
__
()
}}
\begin{methoddesc}
[mapping object]
{__
len
__}{
self
}
...
...
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