blob: b76829c1bbecfcafbde6fbd1290c5a4689a14270 [file] [log] [blame]
Benjamin Petersonf10a79a2008-10-11 00:49:57 +00001****************************
2 What's New in Python 2.7
3****************************
4
5:Author: A.M. Kuchling (amk at amk.ca)
6:Release: |release|
7:Date: |today|
8
9.. $Id$
10 Rules for maintenance:
11
12 * Anyone can add text to this document. Do not spend very much time
13 on the wording of your changes, because your text will probably
14 get rewritten to some degree.
15
16 * The maintainer will go through Misc/NEWS periodically and add
17 changes; it's therefore more important to add your changes to
18 Misc/NEWS than to this file.
19
20 * This is not a complete list of every single change; completeness
21 is the purpose of Misc/NEWS. Some changes I consider too small
22 or esoteric to include. If such a change is added to the text,
23 I'll just remove it. (This is another reason you shouldn't spend
24 too much time on writing your addition.)
25
26 * If you want to draw your new text to the attention of the
27 maintainer, add 'XXX' to the beginning of the paragraph or
28 section.
29
30 * It's OK to just add a fragmentary note about a change. For
31 example: "XXX Describe the transmogrify() function added to the
32 socket module." The maintainer will research the change and
33 write the necessary text.
34
35 * You can comment out your additions if you like, but it's not
36 necessary (especially when a final release is some months away).
37
38 * Credit the author of a patch or bugfix. Just the name is
39 sufficient; the e-mail address isn't necessary.
40
41 * It's helpful to add the bug/patch number in a parenthetical comment.
42
43 XXX Describe the transmogrify() function added to the socket
44 module.
45 (Contributed by P.Y. Developer; :issue:`12345`.)
46
47 This saves the maintainer some effort going through the SVN logs
48 when researching a change.
49
50This article explains the new features in Python 2.7.
51No release schedule has been decided yet for 2.7.
52
53.. Compare with previous release in 2 - 3 sentences here.
54 add hyperlink when the documentation becomes available online.
55
56.. ========================================================================
57.. Large, PEP-level features and changes should be described here.
58.. Should there be a new section here for 3k migration?
59.. Or perhaps a more general section describing module changes/deprecation?
60.. ========================================================================
61
62
Benjamin Petersona54c9092009-01-13 02:11:23 +000063Kristján Valur Jónsson, issue 4293
64Py_AddPendingCall is now thread safe. This allows any worker thread
65to submit notifications to the python main thread. This is particularly
66useful for asynchronous IO operations.
67
Benjamin Petersonf10a79a2008-10-11 00:49:57 +000068
69Other Language Changes
70======================
71
72Some smaller changes made to the core Python language are:
73
Mark Dickinson54bc1ec2008-12-17 16:19:07 +000074* The :func:`int` and :func:`long` types gained a ``bit_length``
75 method that returns the number of bits necessary to represent
76 its argument in binary::
77
78 >>> n = 37
79 >>> bin(37)
80 '0b100101'
81 >>> n.bit_length()
82 6
83 >>> n = 2**123-1
84 >>> n.bit_length()
85 123
86 >>> (n+1).bit_length()
87 124
88
89 (Contributed by Fredrik Johansson and Victor Stinner; :issue:`3439`.)
90
Benjamin Petersonf10a79a2008-10-11 00:49:57 +000091
92.. ======================================================================
93
94
95Optimizations
96-------------
97
98To be written.
99
100.. ======================================================================
101
102New, Improved, and Deprecated Modules
103=====================================
104
105As in every release, Python's standard library received a number of
106enhancements and bug fixes. Here's a partial list of the most notable
107changes, sorted alphabetically by module name. Consult the
108:file:`Misc/NEWS` file in the source tree for a more complete list of
109changes, or look through the Subversion logs for all the details.
110
Georg Brandl1f01deb2009-01-03 22:47:39 +0000111* A new function in the :mod:`subprocess` module,
112 :func:`check_output`, runs a command with a specified set of arguments
113 and returns the command's output as a string if the command runs without
114 error, or raises a :exc:`CalledProcessError` exception otherwise.
115
116 ::
117
118 >>> subprocess.check_output(['df', '-h', '.'])
119 'Filesystem Size Used Avail Capacity Mounted on\n
120 /dev/disk0s2 52G 49G 3.0G 94% /\n'
121
122 >>> subprocess.check_output(['df', '-h', '/bogus'])
123 ...
124 subprocess.CalledProcessError: Command '['df', '-h', '/bogus']' returned non-zero exit status 1
125
126 (Contributed by Gregory P. Smith.)
127
Tarek Ziadé13f7c3b2009-01-09 00:15:45 +0000128* It is not mandatory anymore to store clear text passwords in the
Benjamin Petersona54c9092009-01-13 02:11:23 +0000129 :file:`.pypirc` file when registering and uploading packages to PyPI. As long
130 as the username is present in that file, the :mod:`distutils` package will
131 prompt for the password if not present. (Added by tarek, with the initial
132 contribution of Nathan Van Gheem; :issue:`4394`.)
Benjamin Petersonf10a79a2008-10-11 00:49:57 +0000133
134.. ======================================================================
135.. whole new modules get described in subsections here
136
137.. ======================================================================
138
139
140Build and C API Changes
141=======================
142
143Changes to Python's build process and to the C API include:
144
Georg Brandl1f01deb2009-01-03 22:47:39 +0000145* If you use the :file:`.gdbinit` file provided with Python,
146 the "pyo" macro in the 2.7 version will now work when the thread being
147 debugged doesn't hold the GIL; the macro will now acquire it before printing.
148 (Contributed by haypo XXX; :issue:`3632`.)
Benjamin Petersonf10a79a2008-10-11 00:49:57 +0000149
150.. ======================================================================
151
152Port-Specific Changes: Windows
153-----------------------------------
154
Georg Brandl1f01deb2009-01-03 22:47:39 +0000155* The :mod:`msvcrt` module now contains some constants from
156 the :file:`crtassem.h` header file:
157 :data:`CRT_ASSEMBLY_VERSION`,
158 :data:`VC_ASSEMBLY_PUBLICKEYTOKEN`,
159 and :data:`LIBRARIES_ASSEMBLY_NAME_PREFIX`.
160 (Added by Martin von Loewis (XXX check); :issue:`4365`.)
Benjamin Petersonf10a79a2008-10-11 00:49:57 +0000161
162.. ======================================================================
163
164Port-Specific Changes: Mac OS X
165-----------------------------------
166
167
168.. ======================================================================
169
170Porting to Python 2.7
171=====================
172
173This section lists previously described changes and other bugfixes
174that may require changes to your code:
175
176To be written.
177
178.. ======================================================================
179
180
181.. _acks27:
182
183Acknowledgements
184================
185
186The author would like to thank the following people for offering
187suggestions, corrections and assistance with various drafts of this
188article: no one yet.
189