Commit 7642f7af authored by Andrew M. Kuchling's avatar Andrew M. Kuchling

Credit patch from Raymond

parent 8278860e
...@@ -756,11 +756,13 @@ language. ...@@ -756,11 +756,13 @@ language.
\item The \method{dict.update()} method now accepts the same \item The \method{dict.update()} method now accepts the same
argument forms as the \class{dict} constructor. This includes any argument forms as the \class{dict} constructor. This includes any
mapping, any iterable of key/value pairs, and keyword arguments. mapping, any iterable of key/value pairs, and keyword arguments.
(Contributed by Raymond Hettinger.)
\item The string methods \method{ljust()}, \method{rjust()}, and \item The string methods \method{ljust()}, \method{rjust()}, and
\method{center()} now take an optional argument for specifying a \method{center()} now take an optional argument for specifying a
fill character other than a space. fill character other than a space.
(Contributed by Raymond Hettinger.)
\item Strings also gained an \method{rsplit()} method that \item Strings also gained an \method{rsplit()} method that
works like the \method{split()} method but splits from the end of works like the \method{split()} method but splits from the end of
...@@ -776,6 +778,7 @@ the string. ...@@ -776,6 +778,7 @@ the string.
\item The \method{sort()} method of lists gained three keyword \item The \method{sort()} method of lists gained three keyword
arguments: \var{cmp}, \var{key}, and \var{reverse}. These arguments arguments: \var{cmp}, \var{key}, and \var{reverse}. These arguments
make some common usages of \method{sort()} simpler. All are optional. make some common usages of \method{sort()} simpler. All are optional.
(Contributed by Raymond Hettinger.)
\var{cmp} is the same as the previous single argument to \var{cmp} is the same as the previous single argument to
\method{sort()}; if provided, the value should be a comparison \method{sort()}; if provided, the value should be a comparison
...@@ -860,6 +863,8 @@ red 1 ...@@ -860,6 +863,8 @@ red 1
yellow 5 yellow 5
\end{verbatim} \end{verbatim}
(Contributed by Raymond Hettinger.)
\item Integer operations will no longer trigger an \exception{OverflowWarning}. \item Integer operations will no longer trigger an \exception{OverflowWarning}.
The \exception{OverflowWarning} warning will disappear in Python 2.5. The \exception{OverflowWarning} warning will disappear in Python 2.5.
...@@ -884,7 +889,8 @@ Python dictionary. (Contributed by Raymond Hettinger.) ...@@ -884,7 +889,8 @@ Python dictionary. (Contributed by Raymond Hettinger.)
>>> transpose([]) >>> transpose([])
[] []
\end{verbatim} \end{verbatim}
(Contributed by Raymond Hettinger.)
\item Encountering a failure while importing a module no longer leaves \item Encountering a failure while importing a module no longer leaves
a partially-initialized module object in \code{sys.modules}. The a partially-initialized module object in \code{sys.modules}. The
incomplete module object left behind would fool further imports of the incomplete module object left behind would fool further imports of the
...@@ -892,6 +898,7 @@ same module into succeeding, leading to confusing errors. ...@@ -892,6 +898,7 @@ same module into succeeding, leading to confusing errors.
\item \constant{None} is now a constant; code that binds a new value to \item \constant{None} is now a constant; code that binds a new value to
the name \samp{None} is now a syntax error. the name \samp{None} is now a syntax error.
(Contributed by Raymond Hettinger.)
\end{itemize} \end{itemize}
...@@ -906,6 +913,7 @@ the name \samp{None} is now a syntax error. ...@@ -906,6 +913,7 @@ the name \samp{None} is now a syntax error.
were also optimized for dictionaries, resulting in performance boosts for were also optimized for dictionaries, resulting in performance boosts for
\method{keys()}, \method{values()}, \method{items()}, \method{keys()}, \method{values()}, \method{items()},
\method{iterkeys()}, \method{itervalues()}, and \method{iteritems()}. \method{iterkeys()}, \method{itervalues()}, and \method{iteritems()}.
(Contributed by Raymond Hettinger.)
\item The machinery for growing and shrinking lists was optimized for \item The machinery for growing and shrinking lists was optimized for
speed and for space efficiency. Appending and popping from lists now speed and for space efficiency. Appending and popping from lists now
...@@ -913,12 +921,12 @@ the name \samp{None} is now a syntax error. ...@@ -913,12 +921,12 @@ the name \samp{None} is now a syntax error.
the underlying system \cfunction{realloc()}. List comprehensions the underlying system \cfunction{realloc()}. List comprehensions
also benefit. \method{list.extend()} was also optimized and no also benefit. \method{list.extend()} was also optimized and no
longer converts its argument into a temporary list before extending longer converts its argument into a temporary list before extending
the base list. the base list. (Contributed by Raymond Hettinger.)
\item \function{list()}, \function{tuple()}, \function{map()}, \item \function{list()}, \function{tuple()}, \function{map()},
\function{filter()}, and \function{zip()} now run several times \function{filter()}, and \function{zip()} now run several times
faster with non-sequence arguments that supply a \method{__len__()} faster with non-sequence arguments that supply a \method{__len__()}
method. method. (Contributed by Raymond Hettinger.)
\item The methods \method{list.__getitem__()}, \item The methods \method{list.__getitem__()},
\method{dict.__getitem__()}, and \method{dict.__contains__()} are \method{dict.__getitem__()}, and \method{dict.__contains__()} are
...@@ -927,10 +935,11 @@ the name \samp{None} is now a syntax error. ...@@ -927,10 +935,11 @@ the name \samp{None} is now a syntax error.
access doubles their performance and makes them more suitable for access doubles their performance and makes them more suitable for
use as arguments to functionals: use as arguments to functionals:
\samp{map(mydict.__getitem__, keylist)}. \samp{map(mydict.__getitem__, keylist)}.
(Contributed by Raymond Hettinger.)
\item Added a new opcode, \code{LIST_APPEND}, that simplifies \item Added a new opcode, \code{LIST_APPEND}, that simplifies
the generated bytecode for list comprehensions and speeds them up the generated bytecode for list comprehensions and speeds them up
by about a third. by about a third. (Contributed by Raymond Hettinger.)
\item String concatenations in statements of the form \code{s = s + \item String concatenations in statements of the form \code{s = s +
"abc"} and \code{s += "abc"} are now performed more efficiently in "abc"} and \code{s += "abc"} are now performed more efficiently in
...@@ -938,6 +947,7 @@ certain circumstances. This optimization won't be present in other ...@@ -938,6 +947,7 @@ certain circumstances. This optimization won't be present in other
Python implementations such as Jython, so you shouldn't rely on it; Python implementations such as Jython, so you shouldn't rely on it;
using the \method{join()} method of strings is still recommended when using the \method{join()} method of strings is still recommended when
you want to efficiently glue a large number of strings together. you want to efficiently glue a large number of strings together.
(Contributed by Armin Rigo.)
\end{itemize} \end{itemize}
...@@ -1015,7 +1025,7 @@ True ...@@ -1015,7 +1025,7 @@ True
Several modules now take advantage of \class{collections.deque} for Several modules now take advantage of \class{collections.deque} for
improved performance, such as the \module{Queue} and improved performance, such as the \module{Queue} and
\module{threading} modules. \module{threading} modules. (Contributed by Raymond Hettinger.)
\item The \module{ConfigParser} classes have been enhanced slightly. \item The \module{ConfigParser} classes have been enhanced slightly.
The \method{read()} method now returns a list of the files that The \method{read()} method now returns a list of the files that
...@@ -1044,7 +1054,7 @@ any problems as a \member{defect} attribute of the message. ...@@ -1044,7 +1054,7 @@ any problems as a \member{defect} attribute of the message.
high volumes of data. In addition, the module has two new functions high volumes of data. In addition, the module has two new functions
\function{nlargest()} and \function{nsmallest()} that use heaps to \function{nlargest()} and \function{nsmallest()} that use heaps to
find the N largest or smallest values in a dataset without the find the N largest or smallest values in a dataset without the
expense of a full sort. expense of a full sort. (Contributed by Raymond Hettinger.)
\item The \module{imaplib} module now supports IMAP's THREAD command \item The \module{imaplib} module now supports IMAP's THREAD command
(contributed by Yves Dionne) and new \method{deleteacl()} and (contributed by Yves Dionne) and new \method{deleteacl()} and
...@@ -1103,6 +1113,8 @@ r ['r', 'r'] ...@@ -1103,6 +1113,8 @@ r ['r', 'r']
[('a', 5), ('b', 2), ('c', 1), ('d', 1), ('r', 2)] [('a', 5), ('b', 2), ('c', 1), ('d', 1), ('r', 2)]
\end{verbatim} \end{verbatim}
(Contributed by Hye-Shik Chang.)
\item \module{itertools} also gained a function named \item \module{itertools} also gained a function named
\function{tee(\var{iterator}, \var{N})} that returns \var{N} independent \function{tee(\var{iterator}, \var{N})} that returns \var{N} independent
iterators that replicate \var{iterator}. If \var{N} is omitted, the iterators that replicate \var{iterator}. If \var{N} is omitted, the
...@@ -1127,6 +1139,7 @@ If the separation is large, then you might as well use ...@@ -1127,6 +1139,7 @@ If the separation is large, then you might as well use
\function{list()} instead. When the iterators track closely with one \function{list()} instead. When the iterators track closely with one
another, \function{tee()} is ideal. Possible applications include another, \function{tee()} is ideal. Possible applications include
bookmarking, windowing, or lookahead iterators. bookmarking, windowing, or lookahead iterators.
(Contributed by Raymond Hettinger.)
\item A number of functions were added to the \module{locale} \item A number of functions were added to the \module{locale}
module, such as \function{bind_textdomain_codeset()} to specify a module, such as \function{bind_textdomain_codeset()} to specify a
...@@ -1176,6 +1189,8 @@ data extractors when used with \function{map()} or ...@@ -1176,6 +1189,8 @@ data extractors when used with \function{map()} or
[('d', 1), ('c', 2), ('b', 3), ('a', 4)] [('d', 1), ('c', 2), ('b', 3), ('a', 4)]
\end{verbatim} \end{verbatim}
(Contributed by Raymond Hettinger.)
\item The \module{optparse} module was updated. The module now passes \item The \module{optparse} module was updated. The module now passes
its messages through \function{gettext.gettext()}, making it possible its messages through \function{gettext.gettext()}, making it possible
to internationalize Optik's help and error messages. Help messages to internationalize Optik's help and error messages. Help messages
...@@ -1203,12 +1218,14 @@ not it's a symbolic link. This differs from the existing ...@@ -1203,12 +1218,14 @@ not it's a symbolic link. This differs from the existing
\item The \module{poplib} module now supports POP over SSL. \item The \module{poplib} module now supports POP over SSL.
\item The \module{profile} module can now profile C extension functions. \item The \module{profile} module can now profile C extension functions.
% XXX more to say about this? % XXX more to say about this?
(Contributed by Nick Bastin.)
\item The \module{random} module has a new method called \method{getrandbits(N)} \item The \module{random} module has a new method called \method{getrandbits(N)}
which returns an N-bit long integer. This method supports the existing which returns an N-bit long integer. This method supports the existing
\method{randrange()} method, making it possible to efficiently generate \method{randrange()} method, making it possible to efficiently generate
arbitrarily large random numbers. arbitrarily large random numbers.
(Contributed by Raymond Hettinger.)
\item The regular expression language accepted by the \module{re} module \item The regular expression language accepted by the \module{re} module
was extended with simple conditional expressions, written as was extended with simple conditional expressions, written as
...@@ -1261,11 +1278,12 @@ Other threads can assign and retrieve their own values for the ...@@ -1261,11 +1278,12 @@ Other threads can assign and retrieve their own values for the
\item The \module{timeit} module now automatically disables periodic \item The \module{timeit} module now automatically disables periodic
garbarge collection during the timing loop. This change makes garbarge collection during the timing loop. This change makes
consecutive timings more comparable. consecutive timings more comparable. (Contributed by Raymond Hettinger.)
\item The \module{weakref} module now supports a wider variety of objects \item The \module{weakref} module now supports a wider variety of objects
including Python functions, class instances, sets, frozensets, deques, including Python functions, class instances, sets, frozensets, deques,
arrays, files, sockets, and regular expression pattern objects. arrays, files, sockets, and regular expression pattern objects.
(Contributed by Raymond Hettinger.)
\item The \module{xmlrpclib} module now supports a multi-call extension for \item The \module{xmlrpclib} module now supports a multi-call extension for
transmitting multiple XML-RPC calls in a single HTTP operation. transmitting multiple XML-RPC calls in a single HTTP operation.
...@@ -1315,18 +1333,19 @@ Changes to Python's build process and to the C API include: ...@@ -1315,18 +1333,19 @@ Changes to Python's build process and to the C API include:
\item Three new convenience macros were added for common return \item Three new convenience macros were added for common return
values from extension functions: \csimplemacro{Py_RETURN_NONE}, values from extension functions: \csimplemacro{Py_RETURN_NONE},
\csimplemacro{Py_RETURN_TRUE}, and \csimplemacro{Py_RETURN_FALSE}. \csimplemacro{Py_RETURN_TRUE}, and \csimplemacro{Py_RETURN_FALSE}.
(Contributed by Brett Cannon.)
\item Another new macro, \csimplemacro{Py_CLEAR(\var{obj})}, \item Another new macro, \csimplemacro{Py_CLEAR(\var{obj})},
decreases the reference count of \var{obj} and sets \var{obj} to the decreases the reference count of \var{obj} and sets \var{obj} to the
null pointer. null pointer. (Contributed by Jim Fulton.)
\item A new function, \cfunction{PyTuple_Pack(\var{N}, \var{obj1}, \item A new function, \cfunction{PyTuple_Pack(\var{N}, \var{obj1},
\var{obj2}, ..., \var{objN})}, constructs tuples from a variable \var{obj2}, ..., \var{objN})}, constructs tuples from a variable
length argument list of Python objects. length argument list of Python objects. (Contributed by Raymond Hettinger.)
\item A new function, \cfunction{PyDict_Contains(\var{d}, \var{k})}, \item A new function, \cfunction{PyDict_Contains(\var{d}, \var{k})},
implements fast dictionary lookups without masking exceptions raised implements fast dictionary lookups without masking exceptions raised
during the look-up process. during the look-up process. (Contributed by Raymond Hettinger.)
\item A new function, \cfunction{PyArg_VaParseTupleAndKeywords()}, \item A new function, \cfunction{PyArg_VaParseTupleAndKeywords()},
is the same as \cfunction{PyArg_ParseTupleAndKeywords()} but takes a is the same as \cfunction{PyArg_ParseTupleAndKeywords()} but takes a
...@@ -1336,7 +1355,7 @@ Changes to Python's build process and to the C API include: ...@@ -1336,7 +1355,7 @@ Changes to Python's build process and to the C API include:
\item A new method flag, \constant{METH_COEXISTS}, allows a function \item A new method flag, \constant{METH_COEXISTS}, allows a function
defined in slots to co-exist with a \ctype{PyCFunction} having the defined in slots to co-exist with a \ctype{PyCFunction} having the
same name. This can halve the access time for a method such as same name. This can halve the access time for a method such as
\method{set.__contains__()}. \method{set.__contains__()}. (Contributed by Raymond Hettinger.)
\item Python can now be built with additional profiling for the \item Python can now be built with additional profiling for the
interpreter itself. This is intended for people developing on the interpreter itself. This is intended for people developing on the
...@@ -1359,6 +1378,7 @@ Changes to Python's build process and to the C API include: ...@@ -1359,6 +1378,7 @@ Changes to Python's build process and to the C API include:
\begin{itemize} \begin{itemize}
\item The Windows port now builds under MSVC++ 7.1 as well as version 6. \item The Windows port now builds under MSVC++ 7.1 as well as version 6.
(Contributed by Martin von Loewis.)
\end{itemize} \end{itemize}
...@@ -1375,6 +1395,7 @@ changes to your code: ...@@ -1375,6 +1395,7 @@ changes to your code:
\item The \function{zip()} built-in function and \function{itertools.izip()} \item The \function{zip()} built-in function and \function{itertools.izip()}
now return an empty list instead of raising a \exception{TypeError} now return an empty list instead of raising a \exception{TypeError}
exception if called with no arguments. exception if called with no arguments.
(Contributed by Raymond Hettinger.)
\item \function{dircache.listdir()} now passes exceptions to the caller \item \function{dircache.listdir()} now passes exceptions to the caller
instead of returning empty lists. instead of returning empty lists.
......
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