Commit bd851cd1 authored by Guido van Rossum's avatar Guido van Rossum

* Doc/libtime.tex: get rid of references to millitime() and

	millisleep(); document clock()

	* Doc/ref6.tex (section{Assignment statements}): added warning
	about overlaps in lhs of assignment (e.g. "i, x[i] = 1, 2")
parent d849a483
...@@ -2,8 +2,7 @@ ...@@ -2,8 +2,7 @@
\bimodindex{time} \bimodindex{time}
This module provides various time-related functions. This module provides various time-related functions.
It is always available. (On some systems, not all functions may It is always available.
exist; e.g. the ``milli'' variants can't always be implemented.)
An explanation of some terminology and conventions is in order. An explanation of some terminology and conventions is in order.
...@@ -55,6 +54,13 @@ the same name, there is no trailing newline. ...@@ -55,6 +54,13 @@ the same name, there is no trailing newline.
\end{funcdesc} \end{funcdesc}
\begin{funcdesc}{clock}{}
Return the current CPU time as a floating point number expressed in
seconds. The precision depends on that of the C function by the same
name.
\end{funcdesc}
\begin{funcdesc}{ctime}{secs} \begin{funcdesc}{ctime}{secs}
Convert a time expressed in seconds since the epoch to a string Convert a time expressed in seconds since the epoch to a string
representing local time. \code{ctime(t)} is equivalent to representing local time. \code{ctime(t)} is equivalent to
...@@ -78,18 +84,6 @@ Like \code{gmtime} but converts to local time. The dst flag is set ...@@ -78,18 +84,6 @@ Like \code{gmtime} but converts to local time. The dst flag is set
to 1 when DST applies to the given time. to 1 when DST applies to the given time.
\end{funcdesc} \end{funcdesc}
\begin{funcdesc}{millisleep}{msecs}
Suspend execution for the given number of milliseconds. (Obsolete,
you can now use use \code{sleep} with a floating point argument.)
\end{funcdesc}
\begin{funcdesc}{millitimer}{}
Return the number of milliseconds of real time elapsed since some
point in the past that is fixed per execution of the python
interpreter (but may change in each following run). The return value
may be negative, and it may wrap around.
\end{funcdesc}
\begin{funcdesc}{mktime}{tuple} \begin{funcdesc}{mktime}{tuple}
This is the inverse function of \code{localtime}. Its argument is the This is the inverse function of \code{localtime}. Its argument is the
full 9-tuple (since the dst flag is needed). It returns an integer. full 9-tuple (since the dst flag is needed). It returns an integer.
...@@ -104,8 +98,7 @@ be a floating point number to indicate a more precise sleep time. ...@@ -104,8 +98,7 @@ be a floating point number to indicate a more precise sleep time.
Return the time as a floating point number expressed in seconds since Return the time as a floating point number expressed in seconds since
the epoch, in UTC. Note that even though the time is always returned the epoch, in UTC. Note that even though the time is always returned
as a floating point number, not all systems provide time with a better as a floating point number, not all systems provide time with a better
precision than 1 second. An alternative for measuring precise precision than 1 second.
intervals is \code{millitimer}.
\end{funcdesc} \end{funcdesc}
\begin{datadesc}{timezone} \begin{datadesc}{timezone}
......
...@@ -2,8 +2,7 @@ ...@@ -2,8 +2,7 @@
\bimodindex{time} \bimodindex{time}
This module provides various time-related functions. This module provides various time-related functions.
It is always available. (On some systems, not all functions may It is always available.
exist; e.g. the ``milli'' variants can't always be implemented.)
An explanation of some terminology and conventions is in order. An explanation of some terminology and conventions is in order.
...@@ -55,6 +54,13 @@ the same name, there is no trailing newline. ...@@ -55,6 +54,13 @@ the same name, there is no trailing newline.
\end{funcdesc} \end{funcdesc}
\begin{funcdesc}{clock}{}
Return the current CPU time as a floating point number expressed in
seconds. The precision depends on that of the C function by the same
name.
\end{funcdesc}
\begin{funcdesc}{ctime}{secs} \begin{funcdesc}{ctime}{secs}
Convert a time expressed in seconds since the epoch to a string Convert a time expressed in seconds since the epoch to a string
representing local time. \code{ctime(t)} is equivalent to representing local time. \code{ctime(t)} is equivalent to
...@@ -78,18 +84,6 @@ Like \code{gmtime} but converts to local time. The dst flag is set ...@@ -78,18 +84,6 @@ Like \code{gmtime} but converts to local time. The dst flag is set
to 1 when DST applies to the given time. to 1 when DST applies to the given time.
\end{funcdesc} \end{funcdesc}
\begin{funcdesc}{millisleep}{msecs}
Suspend execution for the given number of milliseconds. (Obsolete,
you can now use use \code{sleep} with a floating point argument.)
\end{funcdesc}
\begin{funcdesc}{millitimer}{}
Return the number of milliseconds of real time elapsed since some
point in the past that is fixed per execution of the python
interpreter (but may change in each following run). The return value
may be negative, and it may wrap around.
\end{funcdesc}
\begin{funcdesc}{mktime}{tuple} \begin{funcdesc}{mktime}{tuple}
This is the inverse function of \code{localtime}. Its argument is the This is the inverse function of \code{localtime}. Its argument is the
full 9-tuple (since the dst flag is needed). It returns an integer. full 9-tuple (since the dst flag is needed). It returns an integer.
...@@ -104,8 +98,7 @@ be a floating point number to indicate a more precise sleep time. ...@@ -104,8 +98,7 @@ be a floating point number to indicate a more precise sleep time.
Return the time as a floating point number expressed in seconds since Return the time as a floating point number expressed in seconds since
the epoch, in UTC. Note that even though the time is always returned the epoch, in UTC. Note that even though the time is always returned
as a floating point number, not all systems provide time with a better as a floating point number, not all systems provide time with a better
precision than 1 second. An alternative for measuring precise precision than 1 second.
intervals is \code{millitimer}.
\end{funcdesc} \end{funcdesc}
\begin{datadesc}{timezone} \begin{datadesc}{timezone}
......
...@@ -190,11 +190,25 @@ target sequence, if the object allows it. ...@@ -190,11 +190,25 @@ target sequence, if the object allows it.
\end{itemize} \end{itemize}
(In the original implementation, the syntax for targets is taken (In the current implementation, the syntax for targets is taken
to be the same as for expressions, and invalid syntax is rejected to be the same as for expressions, and invalid syntax is rejected
during the code generation phase, causing less detailed error during the code generation phase, causing less detailed error
messages.) messages.)
WARNING: Although the definition of assignment implies that overlaps
between the left-hand side and the right-hand side are `safe' (e.g.
\verb@a, b = b, a@ swaps two variables), overlaps within the
collection of assigned-to variables are not safe! For instance, the
following program prints \code@[0, 2]@:
\begin{verbatim}
x = [0, 1]
i = 0
i, x[i] = 1, 2
print x
\end{verbatim}
\section{The {\tt pass} statement} \section{The {\tt pass} statement}
\stindex{pass} \stindex{pass}
......
...@@ -190,11 +190,25 @@ target sequence, if the object allows it. ...@@ -190,11 +190,25 @@ target sequence, if the object allows it.
\end{itemize} \end{itemize}
(In the original implementation, the syntax for targets is taken (In the current implementation, the syntax for targets is taken
to be the same as for expressions, and invalid syntax is rejected to be the same as for expressions, and invalid syntax is rejected
during the code generation phase, causing less detailed error during the code generation phase, causing less detailed error
messages.) messages.)
WARNING: Although the definition of assignment implies that overlaps
between the left-hand side and the right-hand side are `safe' (e.g.
\verb@a, b = b, a@ swaps two variables), overlaps within the
collection of assigned-to variables are not safe! For instance, the
following program prints \code@[0, 2]@:
\begin{verbatim}
x = [0, 1]
i = 0
i, x[i] = 1, 2
print x
\end{verbatim}
\section{The {\tt pass} statement} \section{The {\tt pass} statement}
\stindex{pass} \stindex{pass}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment