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

Skip to content

Commit d39078b

Browse files
committed
Mention timeit module
Fix error in description of logging package's 'propagate' Mention default arg to dict.pop() Link to more module docs (I wonder if I should adopt some convention such as linking the first mention of all new modules to the LibRef?) Various text changes Bump version number and Python version
1 parent ba887bb commit d39078b

1 file changed

Lines changed: 54 additions & 34 deletions

File tree

Doc/whatsnew/whatsnew23.tex

Lines changed: 54 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,21 @@
33
% $Id$
44

55
\title{What's New in Python 2.3}
6-
\release{0.09}
6+
\release{0.10}
77
\author{A.M.\ Kuchling}
88
\authoraddress{\email{[email protected]}}
99

1010
\begin{document}
1111
\maketitle
1212
\tableofcontents
1313

14+
% To do:
1415
% MacOS framework-related changes (section of its own, probably)
1516

1617
%\section{Introduction \label{intro}}
1718

1819
{\large This article is a draft, and is currently up to date for
19-
Python 2.3alpha1. Please send any additions, comments or errata to
20+
Python 2.3alpha2. Please send any additions, comments or errata to
2021
the author.}
2122

2223
This article explains the new features in Python 2.3. The tentative
@@ -511,7 +512,7 @@ \section{PEP 282: The \module{logging} Package}
511512

512513
Log records are usually propagated up the hierarchy, so a message
513514
logged to \samp{server.auth} is also seen by \samp{server} and
514-
\samp{root}, but a handler can prevent this by setting its
515+
\samp{root}, but a \class{Logger} can prevent this by setting its
515516
\member{propagate} attribute to \constant{False}.
516517

517518
There are more classes provided by the \module{logging} package that
@@ -520,16 +521,15 @@ \section{PEP 282: The \module{logging} Package}
520521
number of different \class{Handler} instances. Loggers and handlers
521522
can also have an attached list of filters, and each filter can cause
522523
the \class{LogRecord} to be ignored or can modify the record before
523-
passing it along. \class{LogRecord} instances are converted to text
524-
for output by a \class{Formatter} class. All of these classes can be
525-
replaced by your own specially-written classes.
524+
passing it along. When they're finally output, \class{LogRecord}
525+
instances are converted to text by a \class{Formatter} class. All of
526+
these classes can be replaced by your own specially-written classes.
526527

527528
With all of these features the \module{logging} package should provide
528529
enough flexibility for even the most complicated applications. This
529-
is only a partial overview of the \module{logging} package, so please
530-
see the \ulink{package's reference
531-
documentation}{../lib/module-logging.html} for all of the details.
532-
Reading \pep{282} will also be helpful.
530+
is only an incomplete overview of its features, so please see the
531+
\ulink{package's reference documentation}{../lib/module-logging.html}
532+
for all of the details. Reading \pep{282} will also be helpful.
533533

534534

535535
\begin{seealso}
@@ -1085,11 +1085,11 @@ \section{Other Language Changes}
10851085
\item Built-in types now support the extended slicing syntax,
10861086
as described in section~\ref{section-slices} of this document.
10871087

1088-
\item Dictionaries have a new method, \method{pop(\var{key})}, that
1089-
returns the value corresponding to \var{key} and removes that
1090-
key/value pair from the dictionary. \method{pop()} will raise a
1091-
\exception{KeyError} if the requested key isn't present in the
1092-
dictionary:
1088+
\item Dictionaries have a new method, \method{pop(\var{key}\optional{,
1089+
\var{default}})}, that returns the value corresponding to \var{key}
1090+
and removes that key/value pair from the dictionary. If the requested
1091+
key isn't present in the dictionary, \var{default} is returned if
1092+
it's specified and \exception{KeyError} raised if it isn't.
10931093

10941094
\begin{verbatim}
10951095
>>> d = {1:2}
@@ -1636,9 +1636,8 @@ \section{New, Improved, and Deprecated Modules}
16361636
implements the text wrapping strategy. Both the
16371637
\class{TextWrapper} class and the \function{wrap()} and
16381638
\function{fill()} functions support a number of additional keyword
1639-
arguments for fine-tuning the formatting; consult the module's
1640-
documentation for details.
1641-
%XXX add a link to the module docs?
1639+
arguments for fine-tuning the formatting; consult the \ulink{module's
1640+
documentation}{../lib/module-textwrap.html} for details.
16421641
(Contributed by Greg Ward.)
16431642

16441643
\item The \module{thread} and \module{threading} modules now have
@@ -1648,7 +1647,6 @@ \section{New, Improved, and Deprecated Modules}
16481647
intention is to simplify thread-aware modules (ones that \emph{don't}
16491648
rely on threads to run) by putting the following code at the top:
16501649

1651-
% XXX why as _threading?
16521650
\begin{verbatim}
16531651
try:
16541652
import threading as _threading
@@ -1661,7 +1659,9 @@ \section{New, Improved, and Deprecated Modules}
16611659
statement and making the code slightly clearer. This module will not
16621660
magically make multithreaded code run without threads; code that waits
16631661
for another thread to return or to do something will simply hang
1664-
forever.
1662+
forever. (In this example, \module{_threading} is used as the module
1663+
name to make it clear that the module being used is not necessarily
1664+
the actual \module{threading} module.)
16651665

16661666
\item The \module{time} module's \function{strptime()} function has
16671667
long been an annoyance because it uses the platform C library's
@@ -1670,6 +1670,30 @@ \section{New, Improved, and Deprecated Modules}
16701670
implementation that's written in pure Python and should behave
16711671
identically on all platforms.
16721672

1673+
\item The new \module{timeit} module helps measure how long snippets
1674+
of Python code take to execute. The \file{timeit.py} file can be run
1675+
directly from the command line, or the module's \class{Timer} class
1676+
can be imported and used directly. Here's a short example that
1677+
figures out whether it's faster to convert an 8-bit string to Unicode
1678+
by appending an empty Unicode string to it or by using the
1679+
\function{unicode()} function:
1680+
1681+
\begin{verbatim}
1682+
import timeit
1683+
1684+
timer1 = timeit.Timer('unicode("abc")')
1685+
timer2 = timeit.Timer('"abc" + u""')
1686+
1687+
# Run three trials
1688+
print timer1.repeat(repeat=3, number=100000)
1689+
print timer2.repeat(repeat=3, number=100000)
1690+
1691+
# On my laptop this outputs:
1692+
# [0.36831796169281006, 0.37441694736480713, 0.35304892063140869]
1693+
# [0.17574405670166016, 0.18193507194519043, 0.17565798759460449]
1694+
\end{verbatim}
1695+
1696+
16731697
\item The \module{UserDict} module has a new \class{DictMixin} class which
16741698
defines all dictionary methods for classes that already have a minimum
16751699
mapping interface. This greatly simplifies writing classes that need
@@ -1827,7 +1851,7 @@ \subsection{Date/Time Type}
18271851
\class{date} or \class{datetime}.
18281852

18291853
For more information, refer to the \ulink{module's reference
1830-
documentation}{..//lib/module-datetime.html}.
1854+
documentation}{../lib/module-datetime.html}.
18311855
(Contributed by Tim Peters.)
18321856

18331857

@@ -1900,17 +1924,12 @@ \subsection{The \module{optparse} Module}
19001924
\end{verbatim}
19011925
% $ prevent Emacs tex-mode from getting confused
19021926

1927+
See the \ulink{module's documentation}{../lib/module-optparse.html}
1928+
for more details.
1929+
19031930
Optik was written by Greg Ward, with suggestions from the readers of
19041931
the Getopt SIG.
19051932

1906-
\begin{seealso}
1907-
\seeurl{http://optik.sourceforge.net/}
1908-
{The Optik site has tutorial and reference documentation for
1909-
\module{optparse}.
1910-
% XXX change to point to Python docs, when those docs get written.
1911-
}
1912-
\end{seealso}
1913-
19141933

19151934
%======================================================================
19161935
\section{Specialized Object Allocator (pymalloc)\label{section-pymalloc}}
@@ -2252,10 +2271,11 @@ \section{Acknowledgements \label{acks}}
22522271

22532272
The author would like to thank the following people for offering
22542273
suggestions, corrections and assistance with various drafts of this
2255-
article: Jeff Bauer, Simon Brunning, Michael Chermside, Andrew Dalke, Scott David
2256-
Daniels, Fred~L. Drake, Jr., Kelly Gerber, Raymond Hettinger, Michael
2257-
Hudson, Chris Lambert, Detlef Lannert, Martin von L\"owis, Andrew MacIntyre, Lalo
2258-
Martins, Gustavo Niemeyer, Neal Norwitz, Hans Nowak, Chris Reedy,
2259-
Vinay Sajip, Neil Schemenauer, Roman Suzi, Jason Tishler, Just van~Rossum.
2274+
article: Jeff Bauer, Simon Brunning, Brett Cannon, Michael Chermside,
2275+
Andrew Dalke, Scott David Daniels, Fred~L. Drake, Jr., Kelly Gerber,
2276+
Raymond Hettinger, Michael Hudson, Chris Lambert, Detlef Lannert,
2277+
Martin von L\"owis, Andrew MacIntyre, Lalo Martins, Gustavo Niemeyer,
2278+
Neal Norwitz, Hans Nowak, Chris Reedy, Vinay Sajip, Neil Schemenauer,
2279+
Roman Suzi, Jason Tishler, Just van~Rossum.
22602280

22612281
\end{document}

0 commit comments

Comments
 (0)