close
The Wayback Machine - https://web.archive.org/web/20110606143306/http://docs.python.org/dev/whatsnew/3.3.html

What’s New In Python 3.3

Author:Raymond Hettinger
Release:3.3a0
Date:June 06, 2011

This article explains the new features in Python 3.3, compared to 3.2.

PEP XXX: Stub

Other Language Changes

Some smaller changes made to the core Python language are:

  • Stub

New, Improved, and Deprecated Modules

  • Stub

faulthandler

New module: faulthandler.

math

The math module has a new function:

  • log2(): return the base-2 logarithm of x (Written by Mark Dickinson in issue 11888).

nntplib

The nntplib.NNTP class now supports the context manager protocol to unconditionally consume socket.error exceptions and to close the NNTP connection when done:

>>> from nntplib import NNTP
>>> with nntplib.NNTP('news.gmane.org') as n:
...     n.group('gmane.comp.python.committers')
...
('211 1454 1 1454 gmane.comp.python.committers', '1454', '1', '1454', 'gmane.comp.python.committers')
>>>

(Contributed by Giampaolo Rodolà in issue 9795)

os

  • The os module has a new pipe2() function that makes it possible to create a pipe with O_CLOEXEC or O_NONBLOCK flags set atomically. This is especially useful to avoid race conditions in multi-threaded programs.

  • The os module has a new sendfile() function which provides an efficent “zero-copy” way for copying data from one file (or socket) descriptor to another. The phrase “zero-copy” refers to the fact that all of the copying of data between the two descriptors is done entirely by the kernel, with no copying of data into userspace buffers. sendfile() can be used to efficiently copy data from a file on disk to a network socket, e.g. for downloading a file.

    (Patch submitted by Ross Lagerwall and Giampaolo Rodolà in issue 10882.)

  • The os module has two new functions: getpriority() and setpriority(). They can be used to get or set process niceness/priority in a fashion similar to os.nice() but extended to all processes instead of just the current one.

    (Patch submitted by Giampaolo Rodolà in issue 10784.)

packaging

distutils has undergone additions and refactoring under a new name, packaging, to allow developers to break backward compatibility. distutils is still provided in the standard library, but users are encouraged to transition to packaging. For older versions of Python, a backport compatible with 2.4+ and 3.1+ will be made available on PyPI under the name distutils2.

pydoc

The Tk GUI and the serve() function have been removed from the pydoc module: pydoc -g and serve() have been deprecated in Python 3.2.

sys

signal

  • The signal module has new functions:
  • The signal handler writes the signal number as a single byte instead of a nul byte into the wakeup file descriptor. So it is possible to wait more than one signal and know which signals were raised.
  • signal.signal() and signal.siginterrupt() raise an OSError, instead of a RuntimeError: OSError has an errno attribute.

ssl

The ssl module has new functions:

Optimizations

Major performance enhancements have been added:

  • Stub

Build and C API Changes

Changes to Python’s build process and to the C API include:

  • Stub

Unsupported Operating Systems

OS/2 and VMS are no longer supported due to the lack of a maintainer.

Windows 2000 and Windows platforms which set COMSPEC to command.com are no longer supported due to maintenance burden.

Porting to Python 3.3

This section lists previously described changes and other bugfixes that may require changes to your code:

  • Stub