Changeset 391 for python/trunk/Doc/whatsnew/2.3.rst
- Timestamp:
- Mar 19, 2014, 11:31:01 PM (11 years ago)
- Location:
- python/trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
python/trunk
-
Property svn:mergeinfo
set to
/python/vendor/Python-2.7.6 merged eligible /python/vendor/current merged eligible
-
Property svn:mergeinfo
set to
-
python/trunk/Doc/whatsnew/2.3.rst
r2 r391 367 367 368 368 369 .. index:: 370 single: universal newlines; What's new 371 369 372 PEP 278: Universal Newline Support 370 373 ================================== … … 377 380 two-character sequence of a carriage return plus a newline. 378 381 379 Python's file objects can now support end of line conventions other than the one380 followed by the platform on which Python is running. Opening a file with the 381 mode ``'U'`` or ``'rU'`` will open a file for reading in universal newline mode. 382 All three line ending conventions will be translated to a ``'\n'`` in the 383 strings returned by the various file methods such as :meth:`read` and 384 :meth:`read line`.382 Python's file objects can now support end of line conventions other than the 383 one followed by the platform on which Python is running. Opening a file with 384 the mode ``'U'`` or ``'rU'`` will open a file for reading in :term:`universal 385 newlines` mode. All three line ending conventions will be translated to a 386 ``'\n'`` in the strings returned by the various file methods such as 387 :meth:`read` and :meth:`readline`. 385 388 386 389 Universal newline support is also used when importing modules and when executing … … 1799 1802 Pymalloc, a specialized object allocator written by Vladimir Marangozov, was a 1800 1803 feature added to Python 2.1. Pymalloc is intended to be faster than the system 1801 :c func:`malloc` and to have less memory overhead for allocation patterns typical1802 of Python programs. The allocator uses C's :c func:`malloc` function to get large1804 :c:func:`malloc` and to have less memory overhead for allocation patterns typical 1805 of Python programs. The allocator uses C's :c:func:`malloc` function to get large 1803 1806 pools of memory and then fulfills smaller memory requests from these pools. 1804 1807 … … 1816 1819 There's one particularly common error that causes problems. There are a number 1817 1820 of memory allocation functions in Python's C API that have previously just been 1818 aliases for the C library's :c func:`malloc` and :cfunc:`free`, meaning that if1821 aliases for the C library's :c:func:`malloc` and :c:func:`free`, meaning that if 1819 1822 you accidentally called mismatched functions the error wouldn't be noticeable. 1820 1823 When the object allocator is enabled, these functions aren't aliases of 1821 :c func:`malloc` and :cfunc:`free` any more, and calling the wrong function to1824 :c:func:`malloc` and :c:func:`free` any more, and calling the wrong function to 1822 1825 free memory may get you a core dump. For example, if memory was allocated using 1823 :c func:`PyObject_Malloc`, it has to be freed using :cfunc:`PyObject_Free`, not1824 :c func:`free`. A few modules included with Python fell afoul of this and had to1826 :c:func:`PyObject_Malloc`, it has to be freed using :c:func:`PyObject_Free`, not 1827 :c:func:`free`. A few modules included with Python fell afoul of this and had to 1825 1828 be fixed; doubtless there are more third-party modules that will have the same 1826 1829 problem. … … 1833 1836 1834 1837 * To allocate and free an undistinguished chunk of memory use the "raw memory" 1835 family: :c func:`PyMem_Malloc`, :cfunc:`PyMem_Realloc`, and :cfunc:`PyMem_Free`.1838 family: :c:func:`PyMem_Malloc`, :c:func:`PyMem_Realloc`, and :c:func:`PyMem_Free`. 1836 1839 1837 1840 * The "object memory" family is the interface to the pymalloc facility described 1838 1841 above and is biased towards a large number of "small" allocations: 1839 :c func:`PyObject_Malloc`, :cfunc:`PyObject_Realloc`, and :cfunc:`PyObject_Free`.1842 :c:func:`PyObject_Malloc`, :c:func:`PyObject_Realloc`, and :c:func:`PyObject_Free`. 1840 1843 1841 1844 * To allocate and free Python objects, use the "object" family 1842 :c func:`PyObject_New`, :cfunc:`PyObject_NewVar`, and :cfunc:`PyObject_Del`.1845 :c:func:`PyObject_New`, :c:func:`PyObject_NewVar`, and :c:func:`PyObject_Del`. 1843 1846 1844 1847 Thanks to lots of work by Tim Peters, pymalloc in 2.3 also provides debugging … … 1879 1882 Python's :program:`configure` script. (Contributed by Ondrej Palkovsky.) 1880 1883 1881 * The :c macro:`DL_EXPORT` and :cmacro:`DL_IMPORT` macros are now deprecated.1884 * The :c:macro:`DL_EXPORT` and :c:macro:`DL_IMPORT` macros are now deprecated. 1882 1885 Initialization functions for Python extension modules should now be declared 1883 using the new macro :c macro:`PyMODINIT_FUNC`, while the Python core will1884 generally use the :c macro:`PyAPI_FUNC` and :cmacro:`PyAPI_DATA` macros.1886 using the new macro :c:macro:`PyMODINIT_FUNC`, while the Python core will 1887 generally use the :c:macro:`PyAPI_FUNC` and :c:macro:`PyAPI_DATA` macros. 1885 1888 1886 1889 * The interpreter can be compiled without any docstrings for the built-in … … 1890 1893 by Gustavo Niemeyer.) 1891 1894 1892 * The :c func:`PyArg_NoArgs` macro is now deprecated, and code that uses it1895 * The :c:func:`PyArg_NoArgs` macro is now deprecated, and code that uses it 1893 1896 should be changed. For Python 2.2 and later, the method definition table can 1894 1897 specify the :const:`METH_NOARGS` flag, signalling that there are no arguments, … … 1897 1900 "")`` instead, but this will be slower than using :const:`METH_NOARGS`. 1898 1901 1899 * :c func:`PyArg_ParseTuple` accepts new format characters for various sizes of1900 unsigned integers: ``B`` for :c type:`unsigned char`, ``H`` for :ctype:`unsigned1901 short int`, ``I`` for :c type:`unsigned int`, and ``K`` for :ctype:`unsigned1902 * :c:func:`PyArg_ParseTuple` accepts new format characters for various sizes of 1903 unsigned integers: ``B`` for :c:type:`unsigned char`, ``H`` for :c:type:`unsigned 1904 short int`, ``I`` for :c:type:`unsigned int`, and ``K`` for :c:type:`unsigned 1902 1905 long long`. 1903 1906 1904 * A new function, :c func:`PyObject_DelItemString(mapping, char \*key)` was added1907 * A new function, :c:func:`PyObject_DelItemString(mapping, char \*key)` was added 1905 1908 as shorthand for ``PyObject_DelItem(mapping, PyString_New(key))``. 1906 1909 … … 1912 1915 * It's now possible to define class and static methods for a C extension type by 1913 1916 setting either the :const:`METH_CLASS` or :const:`METH_STATIC` flags in a 1914 method's :c type:`PyMethodDef` structure.1917 method's :c:type:`PyMethodDef` structure. 1915 1918 1916 1919 * Python now includes a copy of the Expat XML parser's source code, removing any
Note:
See TracChangeset
for help on using the changeset viewer.