Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 6cf09f0

Browse files
committed
Patch 543387. Document deprecation of complex %, //,and divmod().
1 parent 97394bc commit 6cf09f0

3 files changed

Lines changed: 21 additions & 10 deletions

File tree

Doc/lib/libfuncs.tex

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -248,9 +248,9 @@ \section{Built-in Functions \label{built-in-funcs}}
248248
\end{funcdesc}
249249

250250
\begin{funcdesc}{divmod}{a, b}
251-
Take two numbers as arguments and return a pair of numbers consisting
252-
of their quotient and remainder when using long division. With mixed
253-
operand types, the rules for binary arithmetic operators apply. For
251+
Take two (non complex) numbers as arguments and return a pair of numbers
252+
consisting of their quotient and remainder when using long division. With
253+
mixed operand types, the rules for binary arithmetic operators apply. For
254254
plain and long integers, the result is the same as
255255
\code{(\var{a} / \var{b}, \var{a} \%{} \var{b})}.
256256
For floating point numbers the result is \code{(\var{q}, \var{a} \%{}

Doc/lib/libstdtypes.tex

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -218,8 +218,8 @@ \subsection{Numeric Types \label{typesnumeric}}
218218
\bifuncindex{float}
219219
\bifuncindex{complex}
220220

221-
All numeric types support the following operations, sorted by
222-
ascending priority (operations in the same box have the same
221+
All numeric types (except complex) support the following operations,
222+
sorted by ascending priority (operations in the same box have the same
223223
priority; all numeric operations have a higher priority than
224224
comparison operations):
225225

@@ -229,7 +229,7 @@ \subsection{Numeric Types \label{typesnumeric}}
229229
\hline
230230
\lineiii{\var{x} * \var{y}}{product of \var{x} and \var{y}}{}
231231
\lineiii{\var{x} / \var{y}}{quotient of \var{x} and \var{y}}{(1)}
232-
\lineiii{\var{x} \%{} \var{y}}{remainder of \code{\var{x} / \var{y}}}{}
232+
\lineiii{\var{x} \%{} \var{y}}{remainder of \code{\var{x} / \var{y}}}{(4)}
233233
\hline
234234
\lineiii{-\var{x}}{\var{x} negated}{}
235235
\lineiii{+\var{x}}{\var{x} unchanged}{}
@@ -240,7 +240,7 @@ \subsection{Numeric Types \label{typesnumeric}}
240240
\lineiii{float(\var{x})}{\var{x} converted to floating point}{}
241241
\lineiii{complex(\var{re},\var{im})}{a complex number with real part \var{re}, imaginary part \var{im}. \var{im} defaults to zero.}{}
242242
\lineiii{\var{c}.conjugate()}{conjugate of the complex number \var{c}}{}
243-
\lineiii{divmod(\var{x}, \var{y})}{the pair \code{(\var{x} / \var{y}, \var{x} \%{} \var{y})}}{(3)}
243+
\lineiii{divmod(\var{x}, \var{y})}{the pair \code{(\var{x} / \var{y}, \var{x} \%{} \var{y})}}{(3)(4)}
244244
\lineiii{pow(\var{x}, \var{y})}{\var{x} to the power \var{y}}{}
245245
\lineiii{\var{x} ** \var{y}}{\var{x} to the power \var{y}}{}
246246
\end{tableiii}
@@ -273,6 +273,12 @@ \subsection{Numeric Types \label{typesnumeric}}
273273
See section \ref{built-in-funcs}, ``Built-in Functions,'' for a full
274274
description.
275275

276+
\item[(4)]
277+
Complex floor division operator, modulo operator, and \function{divmod()}.
278+
279+
\deprecated{2.3}{Instead convert to float using \function{abs()}
280+
if appropriate.}
281+
276282
\end{description}
277283
% XXXJH exceptions: overflow (when? what operations?) zerodivision
278284

Doc/ref/ref5.tex

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -689,16 +689,21 @@ \section{Binary arithmetic operations\label{binary}}
689689
following identity: \code{x == (x/y)*y + (x\%y)}. Integer division and
690690
modulo are also connected with the built-in function \function{divmod()}:
691691
\code{divmod(x, y) == (x/y, x\%y)}. These identities don't hold for
692-
floating point and complex numbers; there similar identities hold
692+
floating point numbers; there similar identities hold
693693
approximately where \code{x/y} is replaced by \code{floor(x/y)}) or
694694
\code{floor(x/y) - 1} (for floats),\footnote{
695695
If x is very close to an exact integer multiple of y, it's
696696
possible for \code{floor(x/y)} to be one larger than
697697
\code{(x-x\%y)/y} due to rounding. In such cases, Python returns
698698
the latter result, in order to preserve that \code{divmod(x,y)[0]
699699
* y + x \%{} y} be very close to \code{x}.
700-
} or \code{floor((x/y).real)} (for
701-
complex).
700+
}.
701+
702+
Complex floor division operator, modulo operator, and
703+
\function{divmod()}.
704+
705+
\deprecated{2.3}{Instead convert to float using \function{abs()}
706+
if appropriate.}
702707
703708
The \code{+} (addition) operator yields the sum of its arguments.
704709
The arguments must either both be numbers or both sequences of the

0 commit comments

Comments
 (0)