Commit 5c4cf158 authored by Fred Drake's avatar Fred Drake

Normalize whitespace.

Fix a number of markup consistency buglets.
parent f2928eb0
...@@ -48,7 +48,7 @@ sets that can't be modified, and can be used as dictionary keys. Sets ...@@ -48,7 +48,7 @@ sets that can't be modified, and can be used as dictionary keys. Sets
are built on top of dictionaries, so the elements within a set must be are built on top of dictionaries, so the elements within a set must be
hashable. hashable.
As a simple example, As a simple example,
\begin{verbatim} \begin{verbatim}
>>> import sets >>> import sets
...@@ -63,12 +63,12 @@ False ...@@ -63,12 +63,12 @@ False
>>> S.remove(3) >>> S.remove(3)
>>> S >>> S
Set([1, 2, 5]) Set([1, 2, 5])
>>> >>>
\end{verbatim} \end{verbatim}
The union and intersection of sets can be computed with the The union and intersection of sets can be computed with the
\method{union()} and \method{intersection()} methods, or, \method{union()} and \method{intersection()} methods, or,
alternatively, using the bitwise operators \samp{\&} and \samp{|}. alternatively, using the bitwise operators \code{\&} and \code{|}.
Mutable sets also have in-place versions of these methods, Mutable sets also have in-place versions of these methods,
\method{union_update()} and \method{intersection_update()}. \method{union_update()} and \method{intersection_update()}.
...@@ -79,7 +79,7 @@ Mutable sets also have in-place versions of these methods, ...@@ -79,7 +79,7 @@ Mutable sets also have in-place versions of these methods,
Set([1, 2, 3, 4, 5, 6]) Set([1, 2, 3, 4, 5, 6])
>>> S1 | S2 # Alternative notation >>> S1 | S2 # Alternative notation
Set([1, 2, 3, 4, 5, 6]) Set([1, 2, 3, 4, 5, 6])
>>> S1.intersection(S2) >>> S1.intersection(S2)
Set([]) Set([])
>>> S1 & S2 # Alternative notation >>> S1 & S2 # Alternative notation
Set([]) Set([])
...@@ -87,7 +87,7 @@ Set([]) ...@@ -87,7 +87,7 @@ Set([])
Set([1, 2, 3, 4, 5, 6]) Set([1, 2, 3, 4, 5, 6])
>>> S1 >>> S1
Set([1, 2, 3, 4, 5, 6]) Set([1, 2, 3, 4, 5, 6])
>>> >>>
\end{verbatim} \end{verbatim}
It's also possible to take the symmetric difference of two sets. This It's also possible to take the symmetric difference of two sets. This
...@@ -165,7 +165,7 @@ def generate_ints(N): ...@@ -165,7 +165,7 @@ def generate_ints(N):
A new keyword, \keyword{yield}, was introduced for generators. Any A new keyword, \keyword{yield}, was introduced for generators. Any
function containing a \keyword{yield} statement is a generator function containing a \keyword{yield} statement is a generator
function; this is detected by Python's bytecode compiler which function; this is detected by Python's bytecode compiler which
compiles the function specially as a result. compiles the function specially as a result.
When you call a generator function, it doesn't return a single value; When you call a generator function, it doesn't return a single value;
instead it returns a generator object that supports the iterator instead it returns a generator object that supports the iterator
...@@ -239,7 +239,7 @@ Two other examples in \file{Lib/test/test_generators.py} produce ...@@ -239,7 +239,7 @@ Two other examples in \file{Lib/test/test_generators.py} produce
solutions for the N-Queens problem (placing $N$ queens on an $NxN$ solutions for the N-Queens problem (placing $N$ queens on an $NxN$
chess board so that no queen threatens another) and the Knight's Tour chess board so that no queen threatens another) and the Knight's Tour
(a route that takes a knight to every square of an $NxN$ chessboard (a route that takes a knight to every square of an $NxN$ chessboard
without visiting any square twice). without visiting any square twice).
The idea of generators comes from other programming languages, The idea of generators comes from other programming languages,
especially Icon (\url{http://www.cs.arizona.edu/icon/}), where the especially Icon (\url{http://www.cs.arizona.edu/icon/}), where the
...@@ -293,7 +293,7 @@ file. For example, a UTF-8 file can be declared with: ...@@ -293,7 +293,7 @@ file. For example, a UTF-8 file can be declared with:
\end{verbatim} \end{verbatim}
Without such an encoding declaration, the default encoding used is Without such an encoding declaration, the default encoding used is
ISO-8859-1, also known as Latin1. ISO-8859-1, also known as Latin1.
The encoding declaration only affects Unicode string literals; the The encoding declaration only affects Unicode string literals; the
text in the source code will be converted to Unicode using the text in the source code will be converted to Unicode using the
...@@ -356,24 +356,24 @@ plus a newline. ...@@ -356,24 +356,24 @@ plus a newline.
Python's file objects can now support end of line conventions other Python's file objects can now support end of line conventions other
than the one followed by the platform on which Python is running. than the one followed by the platform on which Python is running.
Opening a file with the mode \samp{U} or \samp{rU} will open a file Opening a file with the mode \code{'U'} or \code{'rU'} will open a file
for reading in universal newline mode. All three line ending for reading in universal newline mode. All three line ending
conventions will be translated to a \samp{\e n} in the strings conventions will be translated to a \character{\e n} in the strings
returned by the various file methods such as \method{read()} and returned by the various file methods such as \method{read()} and
\method{readline()}. \method{readline()}.
Universal newline support is also used when importing modules and when Universal newline support is also used when importing modules and when
executing a file with the \function{execfile()} function. This means executing a file with the \function{execfile()} function. This means
that Python modules can be shared between all three operating systems that Python modules can be shared between all three operating systems
without needing to convert the line-endings. without needing to convert the line-endings.
This feature can be disabled at compile-time by specifying This feature can be disabled at compile-time by specifying
\longprogramopt{without-universal-newlines} when running Python's \longprogramopt{without-universal-newlines} when running Python's
\file{configure} script. \program{configure} script.
\begin{seealso} \begin{seealso}
\seepep{278}{Universal Newline Support}{Written \seepep{278}{Universal Newline Support}{Written
and implemented by Jack Jansen.} and implemented by Jack Jansen.}
\end{seealso} \end{seealso}
...@@ -408,7 +408,7 @@ for i, item in enumerate(L): ...@@ -408,7 +408,7 @@ for i, item in enumerate(L):
\begin{seealso} \begin{seealso}
\seepep{279}{The enumerate() built-in function}{Written \seepep{279}{The enumerate() built-in function}{Written
by Raymond D. Hettinger.} by Raymond D. Hettinger.}
\end{seealso} \end{seealso}
...@@ -449,7 +449,7 @@ False ...@@ -449,7 +449,7 @@ False
Python's Booleans were added with the primary goal of making code Python's Booleans were added with the primary goal of making code
clearer. For example, if you're reading a function and encounter the clearer. For example, if you're reading a function and encounter the
statement \code{return 1}, you might wonder whether the \samp{1} statement \code{return 1}, you might wonder whether the \code{1}
represents a truth value, or whether it's an index, or whether it's a represents a truth value, or whether it's an index, or whether it's a
coefficient that multiplies some other quantity. If the statement is coefficient that multiplies some other quantity. If the statement is
\code{return True}, however, the meaning of the return value is quite \code{return True}, however, the meaning of the return value is quite
...@@ -479,7 +479,8 @@ random object, and the Boolean type is a subclass of the ...@@ -479,7 +479,8 @@ random object, and the Boolean type is a subclass of the
To sum up \constant{True} and \constant{False} in a sentence: they're To sum up \constant{True} and \constant{False} in a sentence: they're
alternative ways to spell the integer values 1 and 0, with the single alternative ways to spell the integer values 1 and 0, with the single
difference that \function{str()} and \function{repr()} return the difference that \function{str()} and \function{repr()} return the
strings \samp{True} and \samp{False} instead of \samp{1} and \samp{0}. strings \code{'True'} and \code{'False'} instead of \code{'1'} and
\code{'0'}.
\begin{seealso} \begin{seealso}
...@@ -517,7 +518,7 @@ XML character references. ...@@ -517,7 +518,7 @@ XML character references.
\begin{seealso} \begin{seealso}
\seepep{293}{Codec Error Handling Callbacks}{Written and implemented by \seepep{293}{Codec Error Handling Callbacks}{Written and implemented by
Walter D\"orwald.} Walter D\"orwald.}
\end{seealso} \end{seealso}
...@@ -533,7 +534,7 @@ legal Python syntax: \code{L[1:10:2]}, \code{L[:-1:1]}, ...@@ -533,7 +534,7 @@ legal Python syntax: \code{L[1:10:2]}, \code{L[:-1:1]},
the developers of Numerical Python. However, the built-in sequence the developers of Numerical Python. However, the built-in sequence
types of lists, tuples, and strings have never supported this feature, types of lists, tuples, and strings have never supported this feature,
and you got a \exception{TypeError} if you tried it. Michael Hudson and you got a \exception{TypeError} if you tried it. Michael Hudson
contributed a patch that was applied to Python 2.3 and fixed this contributed a patch that was applied to Python 2.3 and fixed this
shortcoming. shortcoming.
For example, you can now easily extract the elements of a list that For example, you can now easily extract the elements of a list that
...@@ -638,9 +639,9 @@ class FakeSeq: ...@@ -638,9 +639,9 @@ class FakeSeq:
... ...
def __getitem__(self, item): def __getitem__(self, item):
if isinstance(item, slice): if isinstance(item, slice):
return FakeSeq([self.calc_item(i) return FakeSeq([self.calc_item(i)
in range(*item.indices(len(self)))]) in range(*item.indices(len(self)))])
else: else:
return self.calc_item(i) return self.calc_item(i)
\end{verbatim} \end{verbatim}
...@@ -660,7 +661,7 @@ language. ...@@ -660,7 +661,7 @@ language.
\item The \keyword{yield} statement is now always a keyword, as \item The \keyword{yield} statement is now always a keyword, as
described in section~\ref{section-generators} of this document. described in section~\ref{section-generators} of this document.
\item A new built-in function \function{enumerate()} \item A new built-in function \function{enumerate()}
was added, as described in section~\ref{section-enumerate} of this was added, as described in section~\ref{section-enumerate} of this
document. document.
...@@ -668,7 +669,7 @@ document. ...@@ -668,7 +669,7 @@ document.
added along with the built-in \class{bool} type, as described in added along with the built-in \class{bool} type, as described in
section~\ref{section-bool} of this document. section~\ref{section-bool} of this document.
\item Built-in types now support the extended slicing syntax, \item Built-in types now support the extended slicing syntax,
as described in section~\ref{section-slices} of this document. as described in section~\ref{section-slices} of this document.
\item Dictionaries have a new method, \method{pop(\var{key})}, that \item Dictionaries have a new method, \method{pop(\var{key})}, that
...@@ -700,7 +701,7 @@ KeyError: pop(): dictionary is empty ...@@ -700,7 +701,7 @@ KeyError: pop(): dictionary is empty
\item The \keyword{assert} statement no longer checks the \code{__debug__} \item The \keyword{assert} statement no longer checks the \code{__debug__}
flag, so you can no longer disable assertions by assigning to \code{__debug__}. flag, so you can no longer disable assertions by assigning to \code{__debug__}.
Running Python with the \programopt{-O} switch will still generate Running Python with the \programopt{-O} switch will still generate
code that doesn't execute any assertions. code that doesn't execute any assertions.
\item Most type objects are now callable, so you can use them \item Most type objects are now callable, so you can use them
...@@ -720,7 +721,7 @@ For example, you can create a new module object with the following code: ...@@ -720,7 +721,7 @@ For example, you can create a new module object with the following code:
'docstring' 'docstring'
\end{verbatim} \end{verbatim}
\item \item
A new warning, \exception{PendingDeprecationWarning} was added to A new warning, \exception{PendingDeprecationWarning} was added to
indicate features which are in the process of being indicate features which are in the process of being
deprecated. The warning will \emph{not} be printed by default. To deprecated. The warning will \emph{not} be printed by default. To
...@@ -742,7 +743,7 @@ by setting the limit back to a lower number by calling ...@@ -742,7 +743,7 @@ by setting the limit back to a lower number by calling
\item One minor but far-reaching change is that the names of extension \item One minor but far-reaching change is that the names of extension
types defined by the modules included with Python now contain the types defined by the modules included with Python now contain the
module and a \samp{.} in front of the type name. For example, in module and a \character{.} in front of the type name. For example, in
Python 2.2, if you created a socket and printed its Python 2.2, if you created a socket and printed its
\member{__class__}, you'd get this output: \member{__class__}, you'd get this output:
...@@ -825,7 +826,7 @@ than \method{zfill()}. ...@@ -825,7 +826,7 @@ than \method{zfill()}.
(Contributed by Walter D\"orwald.) (Contributed by Walter D\"orwald.)
\item A new type object, \class{basestring}, has been added. \item A new type object, \class{basestring}, has been added.
Both 8-bit strings and Unicode strings inherit from this type, so Both 8-bit strings and Unicode strings inherit from this type, so
\code{isinstance(obj, basestring)} will return \constant{True} for \code{isinstance(obj, basestring)} will return \constant{True} for
either kind of string. It's a completely abstract type, so you either kind of string. It's a completely abstract type, so you
...@@ -878,16 +879,16 @@ details. ...@@ -878,16 +879,16 @@ details.
\begin{itemize} \begin{itemize}
\item The \module{array} module now supports arrays of Unicode \item The \module{array} module now supports arrays of Unicode
characters using the \samp{u} format character. Arrays also now characters using the \character{u} format character. Arrays also now
support using the \code{+=} assignment operator to add another array's support using the \code{+=} assignment operator to add another array's
contents, and the \code{*=} assignment operator to repeat an array. contents, and the \code{*=} assignment operator to repeat an array.
(Contributed by Jason Orendorff.) (Contributed by Jason Orendorff.)
\item The Distutils \class{Extension} class now supports \item The Distutils \class{Extension} class now supports
an extra constructor argument named \samp{depends} for listing an extra constructor argument named \var{depends} for listing
additional source files that an extension depends on. This lets additional source files that an extension depends on. This lets
Distutils recompile the module if any of the dependency files are Distutils recompile the module if any of the dependency files are
modified. For example, if \samp{sampmodule.c} includes the header modified. For example, if \file{sampmodule.c} includes the header
file \file{sample.h}, you would create the \class{Extension} object like file \file{sample.h}, you would create the \class{Extension} object like
this: this:
...@@ -909,7 +910,7 @@ recently-added extensions to Distutils. ...@@ -909,7 +910,7 @@ recently-added extensions to Distutils.
\item The \module{getopt} module gained a new function, \item The \module{getopt} module gained a new function,
\function{gnu_getopt()}, that supports the same arguments as the existing \function{gnu_getopt()}, that supports the same arguments as the existing
\function{getopt()} function but uses GNU-style scanning mode. \function{getopt()} function but uses GNU-style scanning mode.
The existing \function{getopt()} stops processing options as soon as a The existing \function{getopt()} stops processing options as soon as a
non-option argument is encountered, but in GNU-style mode processing non-option argument is encountered, but in GNU-style mode processing
continues, meaning that options and arguments can be mixed. For continues, meaning that options and arguments can be mixed. For
...@@ -925,7 +926,7 @@ example: ...@@ -925,7 +926,7 @@ example:
(Contributed by Peter \AA{strand}.) (Contributed by Peter \AA{strand}.)
\item The \module{grp}, \module{pwd}, and \module{resource} modules \item The \module{grp}, \module{pwd}, and \module{resource} modules
now return enhanced tuples: now return enhanced tuples:
\begin{verbatim} \begin{verbatim}
>>> import grp >>> import grp
...@@ -981,9 +982,9 @@ sequence type. For example: ...@@ -981,9 +982,9 @@ sequence type. For example:
(Contributed by Kevin O'Connor.) (Contributed by Kevin O'Connor.)
\item Two new functions in the \module{math} module, \item Two new functions in the \module{math} module,
\function{degrees(\var{rads})} and \function{radians(\var{degs})}, \function{degrees(\var{rads})} and \function{radians(\var{degs})},
convert between radians and degrees. Other functions in the convert between radians and degrees. Other functions in the
\module{math} module such as \module{math} module such as
\function{math.sin()} and \function{math.cos()} have always required \function{math.sin()} and \function{math.cos()} have always required
input values measured in radians. (Contributed by Raymond Hettinger.) input values measured in radians. (Contributed by Raymond Hettinger.)
...@@ -994,10 +995,10 @@ input values measured in radians. (Contributed by Raymond Hettinger.) ...@@ -994,10 +995,10 @@ input values measured in radians. (Contributed by Raymond Hettinger.)
\module{posix} module that underlies the \module{os} module. \module{posix} module that underlies the \module{os} module.
(Contributed by Gustavo Niemeyer and Geert Jansen.) (Contributed by Gustavo Niemeyer and Geert Jansen.)
\item The parser objects provided by the \module{pyexpat} module \item The parser objects provided by the \module{pyexpat} module
can now optionally buffer character data, resulting in fewer calls to can now optionally buffer character data, resulting in fewer calls to
your character data handler and therefore faster performance. Setting your character data handler and therefore faster performance. Setting
the parser object's \member{buffer_text} attribute to \constant{True} the parser object's \member{buffer_text} attribute to \constant{True}
will enable buffering. will enable buffering.
\item The \function{sample(\var{population}, \var{k})} function was \item The \function{sample(\var{population}, \var{k})} function was
...@@ -1039,7 +1040,7 @@ unavoidable race conditions. ...@@ -1039,7 +1040,7 @@ unavoidable race conditions.
can call the \method{settimeout(\var{t})} method on a socket object to can call the \method{settimeout(\var{t})} method on a socket object to
set a timeout of \var{t} seconds. Subsequent socket operations that set a timeout of \var{t} seconds. Subsequent socket operations that
take longer than \var{t} seconds to complete will abort and raise a take longer than \var{t} seconds to complete will abort and raise a
\exception{socket.error} exception. \exception{socket.error} exception.
The original timeout implementation was by Tim O'Malley. Michael The original timeout implementation was by Tim O'Malley. Michael
Gilfix integrated it into the Python \module{socket} module, after the Gilfix integrated it into the Python \module{socket} module, after the
...@@ -1047,7 +1048,7 @@ patch had undergone a lengthy review. After it was checked in, Guido ...@@ -1047,7 +1048,7 @@ patch had undergone a lengthy review. After it was checked in, Guido
van~Rossum rewrote parts of it. This is a good example of the free van~Rossum rewrote parts of it. This is a good example of the free
software development process in action. software development process in action.
\item The value of the C \constant{PYTHON_API_VERSION} macro is now exposed \item The value of the C \constant{PYTHON_API_VERSION} macro is now exposed
at the Python level as \code{sys.api_version}. at the Python level as \code{sys.api_version}.
\item The new \module{textwrap} module contains functions for wrapping \item The new \module{textwrap} module contains functions for wrapping
...@@ -1063,8 +1064,8 @@ string, reformatted to fit into lines no longer than the chosen width. ...@@ -1063,8 +1064,8 @@ string, reformatted to fit into lines no longer than the chosen width.
>>> import textwrap >>> import textwrap
>>> paragraph = "Not a whit, we defy augury: ... more text ..." >>> paragraph = "Not a whit, we defy augury: ... more text ..."
>>> textwrap.wrap(paragraph, 60) >>> textwrap.wrap(paragraph, 60)
["Not a whit, we defy augury: there's a special providence in", ["Not a whit, we defy augury: there's a special providence in",
"the fall of a sparrow. If it be now, 'tis not to come; if it", "the fall of a sparrow. If it be now, 'tis not to come; if it",
...] ...]
>>> print textwrap.fill(paragraph, 35) >>> print textwrap.fill(paragraph, 35)
Not a whit, we defy augury: there's Not a whit, we defy augury: there's
...@@ -1073,20 +1074,20 @@ a sparrow. If it be now, 'tis not ...@@ -1073,20 +1074,20 @@ a sparrow. If it be now, 'tis not
to come; if it be not to come, it to come; if it be not to come, it
will be now; if it be not now, yet will be now; if it be not now, yet
it will come: the readiness is all. it will come: the readiness is all.
>>> >>>
\end{verbatim} \end{verbatim}
The module also contains a \class{TextWrapper} class that actually The module also contains a \class{TextWrapper} class that actually
implements the text wrapping strategy. Both the implements the text wrapping strategy. Both the
\class{TextWrapper} class and the \function{wrap()} and \class{TextWrapper} class and the \function{wrap()} and
\function{fill()} functions support a number of additional keyword \function{fill()} functions support a number of additional keyword
arguments for fine-tuning the formatting; consult the module's arguments for fine-tuning the formatting; consult the module's
documentation for details. documentation for details.
% XXX add a link to the module docs? % XXX add a link to the module docs?
(Contributed by Greg Ward.) (Contributed by Greg Ward.)
\item The \module{time} module's \function{strptime()} function has \item The \module{time} module's \function{strptime()} function has
long been an annoyance because it uses the platform C library's long been an annoyance because it uses the platform C library's
\function{strptime()} implementation, and different platforms \function{strptime()} implementation, and different platforms
sometimes have odd bugs. Brett Cannon contributed a portable sometimes have odd bugs. Brett Cannon contributed a portable
implementation that's written in pure Python, which should behave implementation that's written in pure Python, which should behave
...@@ -1190,7 +1191,7 @@ Thanks to lots of work by Tim Peters, pymalloc in 2.3 also provides ...@@ -1190,7 +1191,7 @@ Thanks to lots of work by Tim Peters, pymalloc in 2.3 also provides
debugging features to catch memory overwrites and doubled frees in debugging features to catch memory overwrites and doubled frees in
both extension modules and in the interpreter itself. To enable this both extension modules and in the interpreter itself. To enable this
support, turn on the Python interpreter's debugging code by running support, turn on the Python interpreter's debugging code by running
\program{configure} with \longprogramopt{with-pydebug}. \program{configure} with \longprogramopt{with-pydebug}.
To aid extension writers, a header file \file{Misc/pymemcompat.h} is To aid extension writers, a header file \file{Misc/pymemcompat.h} is
distributed with the source to Python 2.3 that allows Python distributed with the source to Python 2.3 that allows Python
...@@ -1246,7 +1247,7 @@ allocate objects, and \cfunction{PyObject_GC_Del} to deallocate them. ...@@ -1246,7 +1247,7 @@ allocate objects, and \cfunction{PyObject_GC_Del} to deallocate them.
\item Python can now optionally be built as a shared library \item Python can now optionally be built as a shared library
(\file{libpython2.3.so}) by supplying \longprogramopt{enable-shared} (\file{libpython2.3.so}) by supplying \longprogramopt{enable-shared}
when running Python's \file{configure} script. (Contributed by Ondrej when running Python's \program{configure} script. (Contributed by Ondrej
Palkovsky.) Palkovsky.)
\item The \csimplemacro{DL_EXPORT} and \csimplemacro{DL_IMPORT} macros \item The \csimplemacro{DL_EXPORT} and \csimplemacro{DL_IMPORT} macros
...@@ -1256,9 +1257,9 @@ modules should now be declared using the new macro ...@@ -1256,9 +1257,9 @@ modules should now be declared using the new macro
use the \csimplemacro{PyAPI_FUNC} and \csimplemacro{PyAPI_DATA} use the \csimplemacro{PyAPI_FUNC} and \csimplemacro{PyAPI_DATA}
macros. macros.
\item The interpreter can be compiled without any docstrings for \item The interpreter can be compiled without any docstrings for
the built-in functions and modules by supplying the built-in functions and modules by supplying
\longprogramopt{without-doc-strings} to the \file{configure} script. \longprogramopt{without-doc-strings} to the \program{configure} script.
This makes the Python executable about 10\% smaller, but will also This makes the Python executable about 10\% smaller, but will also
mean that you can't get help for Python's built-ins. (Contributed by mean that you can't get help for Python's built-ins. (Contributed by
Gustavo Niemeyer.) Gustavo Niemeyer.)
...@@ -1266,25 +1267,25 @@ Gustavo Niemeyer.) ...@@ -1266,25 +1267,25 @@ Gustavo Niemeyer.)
\item The cycle detection implementation used by the garbage collection \item The cycle detection implementation used by the garbage collection
has proven to be stable, so it's now being made mandatory; you can no has proven to be stable, so it's now being made mandatory; you can no
longer compile Python without it, and the longer compile Python without it, and the
\longprogramopt{with-cycle-gc} switch to \file{configure} has been removed. \longprogramopt{with-cycle-gc} switch to \program{configure} has been removed.
\item The \cfunction{PyArg_NoArgs()} macro is now deprecated, and code \item The \cfunction{PyArg_NoArgs()} macro is now deprecated, and code
that uses it should be changed. For Python 2.2 and later, the method that uses it should be changed. For Python 2.2 and later, the method
definition table can specify the definition table can specify the
\constant{METH_NOARGS} flag, signalling that there are no arguments, and \constant{METH_NOARGS} flag, signalling that there are no arguments, and
the argument checking can then be removed. If compatibility with the argument checking can then be removed. If compatibility with
pre-2.2 versions of Python is important, the code could use pre-2.2 versions of Python is important, the code could use
\code{PyArg_ParseTuple(args, "")} instead, but this will be slower \code{PyArg_ParseTuple(args, "")} instead, but this will be slower
than using \constant{METH_NOARGS}. than using \constant{METH_NOARGS}.
\item A new function, \cfunction{PyObject_DelItemString(\var{mapping}, \item A new function, \cfunction{PyObject_DelItemString(\var{mapping},
char *\var{key})} was added char *\var{key})} was added
as shorthand for as shorthand for
\code{PyObject_DelItem(\var{mapping}, PyString_New(\var{key})}. \code{PyObject_DelItem(\var{mapping}, PyString_New(\var{key})}.
\item File objects now manage their internal string buffer \item File objects now manage their internal string buffer
differently by increasing it exponentially when needed. differently by increasing it exponentially when needed.
This results in the benchmark tests in \file{Lib/test/test_bufio.py} This results in the benchmark tests in \file{Lib/test/test_bufio.py}
speeding up from 57 seconds to 1.7 seconds, according to one speeding up from 57 seconds to 1.7 seconds, according to one
measurement. measurement.
...@@ -1295,7 +1296,7 @@ structure. ...@@ -1295,7 +1296,7 @@ structure.
\item Python now includes a copy of the Expat XML parser's source code, \item Python now includes a copy of the Expat XML parser's source code,
removing any dependence on a system version or local installation of removing any dependence on a system version or local installation of
Expat. Expat.
\end{itemize} \end{itemize}
...@@ -1373,17 +1374,17 @@ variable name in your code, a different name must be chosen. ...@@ -1373,17 +1374,17 @@ variable name in your code, a different name must be chosen.
\item You can no longer disable assertions by assigning to \code{__debug__}. \item You can no longer disable assertions by assigning to \code{__debug__}.
\item Using \code{None} as a variable name will now result in a \item Using \code{None} as a variable name will now result in a
\exception{SyntaxWarning} warning. \exception{SyntaxWarning} warning.
\item Names of extension types defined by the modules included with \item Names of extension types defined by the modules included with
Python now contain the module and a \samp{.} in front of the type Python now contain the module and a \character{.} in front of the type
name. name.
\item For strings \var{X} and \var{Y}, \code{\var{X} in \var{Y}} now works \item For strings \var{X} and \var{Y}, \code{\var{X} in \var{Y}} now works
if \var{X} is more than one character long. if \var{X} is more than one character long.
\item The Distutils \function{setup()} function has gained various new \item The Distutils \function{setup()} function has gained various new
keyword arguments such as \samp{depends}. Old versions of the keyword arguments such as \var{depends}. Old versions of the
Distutils will abort if passed unknown keywords. The fix is to check Distutils will abort if passed unknown keywords. The fix is to check
for the presence of the new \function{get_distutil_options()} function for the presence of the new \function{get_distutil_options()} function
in your \file{setup.py} if you want to only support the new keywords in your \file{setup.py} if you want to only support the new keywords
...@@ -1395,7 +1396,7 @@ from distutils import core ...@@ -1395,7 +1396,7 @@ from distutils import core
kw = {'sources': 'foo.c', ...} kw = {'sources': 'foo.c', ...}
if hasattr(core, 'get_distutil_options'): if hasattr(core, 'get_distutil_options'):
kw['depends'] = ['foo.h'] kw['depends'] = ['foo.h']
ext = Extension(**kw) ext = Extension(**kw)
\end{verbatim} \end{verbatim}
\end{itemize} \end{itemize}
......
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