Fred Drake | 2db7680 | 2004-12-01 05:05:47 +0000 | [diff] [blame] | 1 | \documentclass{howto} |
| 2 | \usepackage{distutils} |
| 3 | % $Id$ |
| 4 | |
Fred Drake | 2db7680 | 2004-12-01 05:05:47 +0000 | [diff] [blame] | 5 | |
| 6 | \title{What's New in Python 2.5} |
| 7 | \release{0.0} |
Andrew M. Kuchling | 92e2495 | 2004-12-03 13:54:09 +0000 | [diff] [blame] | 8 | \author{A.M. Kuchling} |
| 9 | \authoraddress{\email{amk@amk.ca}} |
Fred Drake | 2db7680 | 2004-12-01 05:05:47 +0000 | [diff] [blame] | 10 | |
| 11 | \begin{document} |
| 12 | \maketitle |
| 13 | \tableofcontents |
| 14 | |
| 15 | This article explains the new features in Python 2.5. No release date |
Andrew M. Kuchling | 92e2495 | 2004-12-03 13:54:09 +0000 | [diff] [blame] | 16 | for Python 2.5 has been set; it will probably be released in late 2005. |
Fred Drake | 2db7680 | 2004-12-01 05:05:47 +0000 | [diff] [blame] | 17 | |
| 18 | % Compare with previous release in 2 - 3 sentences here. |
| 19 | |
| 20 | This article doesn't attempt to provide a complete specification of |
| 21 | the new features, but instead provides a convenient overview. For |
| 22 | full details, you should refer to the documentation for Python 2.5. |
| 23 | % add hyperlink when the documentation becomes available online. |
| 24 | If you want to understand the complete implementation and design |
| 25 | rationale, refer to the PEP for a particular new feature. |
| 26 | |
| 27 | |
| 28 | %====================================================================== |
Andrew M. Kuchling | 3e41b05 | 2005-03-01 00:53:46 +0000 | [diff] [blame^] | 29 | \section{PEP 309: Partial Function Application} |
Fred Drake | 2db7680 | 2004-12-01 05:05:47 +0000 | [diff] [blame] | 30 | |
Andrew M. Kuchling | 3e41b05 | 2005-03-01 00:53:46 +0000 | [diff] [blame^] | 31 | XXX describe this PEP. |
Fred Drake | 2db7680 | 2004-12-01 05:05:47 +0000 | [diff] [blame] | 32 | |
| 33 | |
| 34 | %====================================================================== |
| 35 | \section{Other Language Changes} |
| 36 | |
| 37 | Here are all of the changes that Python 2.5 makes to the core Python |
| 38 | language. |
| 39 | |
| 40 | \begin{itemize} |
Andrew M. Kuchling | 1cae3f5 | 2004-12-03 14:57:21 +0000 | [diff] [blame] | 41 | |
| 42 | \item The \function{min()} and \function{max()} built-in functions |
| 43 | gained a \code{key} keyword argument analogous to the \code{key} |
| 44 | argument for \function{sort()}. This argument supplies a function |
| 45 | that takes a single argument and is called for every value in the list; |
| 46 | \function{min()}/\function{max()} will return the element with the |
| 47 | smallest/largest return value from this function. |
| 48 | For example, to find the longest string in a list, you can do: |
| 49 | |
| 50 | \begin{verbatim} |
| 51 | L = ['medium', 'longest', 'short'] |
| 52 | # Prints 'longest' |
| 53 | print max(L, key=len) |
| 54 | # Prints 'short', because lexicographically 'short' has the largest value |
| 55 | print max(L) |
| 56 | \end{verbatim} |
| 57 | |
Andrew M. Kuchling | 3e41b05 | 2005-03-01 00:53:46 +0000 | [diff] [blame^] | 58 | % XXX also supported by heapq.nsmallest() and heapq.nlargest(). |
| 59 | |
Andrew M. Kuchling | 1cae3f5 | 2004-12-03 14:57:21 +0000 | [diff] [blame] | 60 | (Contributed by Steven Bethard and Raymond Hettinger.) |
Fred Drake | 2db7680 | 2004-12-01 05:05:47 +0000 | [diff] [blame] | 61 | |
| 62 | \end{itemize} |
| 63 | |
| 64 | |
| 65 | %====================================================================== |
| 66 | \subsection{Optimizations} |
| 67 | |
| 68 | \begin{itemize} |
| 69 | |
| 70 | \item Optimizations should be described here. |
| 71 | |
| 72 | \end{itemize} |
| 73 | |
| 74 | The net result of the 2.5 optimizations is that Python 2.5 runs the |
Andrew M. Kuchling | 92e2495 | 2004-12-03 13:54:09 +0000 | [diff] [blame] | 75 | pystone benchmark around XX\% faster than Python 2.4. |
Fred Drake | 2db7680 | 2004-12-01 05:05:47 +0000 | [diff] [blame] | 76 | |
| 77 | |
| 78 | %====================================================================== |
| 79 | \section{New, Improved, and Deprecated Modules} |
| 80 | |
| 81 | As usual, Python's standard library received a number of enhancements and |
| 82 | bug fixes. Here's a partial list of the most notable changes, sorted |
| 83 | alphabetically by module name. Consult the |
| 84 | \file{Misc/NEWS} file in the source tree for a more |
| 85 | complete list of changes, or look through the CVS logs for all the |
| 86 | details. |
| 87 | |
| 88 | \begin{itemize} |
| 89 | |
Andrew M. Kuchling | 3e41b05 | 2005-03-01 00:53:46 +0000 | [diff] [blame^] | 90 | % the cPickle module no longer accepts the deprecated None option in the |
| 91 | % args tuple returned by __reduce__(). |
| 92 | |
| 93 | % csv module improvements |
| 94 | |
| 95 | % datetime.datetime() now has a strptime class method which can be used to |
| 96 | % create datetime object using a string and format. |
| 97 | |
| 98 | % itertools.islice() now accepts None for the start and step arguments. |
| 99 | |
| 100 | \item New module: \module{spwd} provides functions for accessing the |
| 101 | shadow password database on systems that support it. |
| 102 | % XXX give example |
| 103 | |
| 104 | % XXX os.stat_float_times is now True |
| 105 | |
| 106 | % os.{SEEK_SET, SEEK_CUR, SEEK_END} have been added for convenience. |
Fred Drake | 2db7680 | 2004-12-01 05:05:47 +0000 | [diff] [blame] | 107 | |
| 108 | \end{itemize} |
| 109 | |
| 110 | |
| 111 | %====================================================================== |
| 112 | % whole new modules get described in \subsections here |
| 113 | |
| 114 | |
| 115 | % ====================================================================== |
| 116 | \section{Build and C API Changes} |
| 117 | |
| 118 | Changes to Python's build process and to the C API include: |
| 119 | |
| 120 | \begin{itemize} |
| 121 | |
Andrew M. Kuchling | 2238fc6 | 2004-12-03 15:16:40 +0000 | [diff] [blame] | 122 | \item The \cfunction{PyRange_New()} function was removed. It was never documented, |
| 123 | never used in the core code, and had dangerously lax error checking. |
Fred Drake | 2db7680 | 2004-12-01 05:05:47 +0000 | [diff] [blame] | 124 | |
| 125 | \end{itemize} |
| 126 | |
| 127 | |
| 128 | %====================================================================== |
| 129 | \subsection{Port-Specific Changes} |
| 130 | |
| 131 | Platform-specific changes go here. |
| 132 | |
| 133 | |
| 134 | %====================================================================== |
| 135 | \section{Other Changes and Fixes \label{section-other}} |
| 136 | |
| 137 | As usual, there were a bunch of other improvements and bugfixes |
| 138 | scattered throughout the source tree. A search through the CVS change |
| 139 | logs finds there were XXX patches applied and YYY bugs fixed between |
Andrew M. Kuchling | 92e2495 | 2004-12-03 13:54:09 +0000 | [diff] [blame] | 140 | Python 2.4 and 2.5. Both figures are likely to be underestimates. |
Fred Drake | 2db7680 | 2004-12-01 05:05:47 +0000 | [diff] [blame] | 141 | |
| 142 | Some of the more notable changes are: |
| 143 | |
| 144 | \begin{itemize} |
| 145 | |
| 146 | \item Details go here. |
| 147 | |
| 148 | \end{itemize} |
| 149 | |
| 150 | |
| 151 | %====================================================================== |
| 152 | \section{Porting to Python 2.5} |
| 153 | |
| 154 | This section lists previously described changes that may require |
| 155 | changes to your code: |
| 156 | |
| 157 | \begin{itemize} |
| 158 | |
Andrew M. Kuchling | 3e41b05 | 2005-03-01 00:53:46 +0000 | [diff] [blame^] | 159 | \item Some old deprecated modules (\module{statcache}, \module{tzparse}, |
| 160 | \module{whrandom}) have been moved to \file{Lib/lib-old}. |
| 161 | % XXX note how to get them back |
| 162 | |
| 163 | % the pickle module no longer uses the deprecated bin parameter. |
Fred Drake | 2db7680 | 2004-12-01 05:05:47 +0000 | [diff] [blame] | 164 | |
| 165 | \end{itemize} |
| 166 | |
| 167 | |
| 168 | %====================================================================== |
| 169 | \section{Acknowledgements \label{acks}} |
| 170 | |
| 171 | The author would like to thank the following people for offering |
| 172 | suggestions, corrections and assistance with various drafts of this |
| 173 | article: . |
| 174 | |
| 175 | \end{document} |