Traceback (most recent call last):
...
TypeError: f() takes at least 1 argument (0 given)
Contributed by George Sakkis; issue 3135.
• Updated module: The io library has been upgraded to the version shipped with Python 3.1. For 3.1, the
I/O library was entirely rewritten in C and is 2 to 20 times faster depending on the task being performed.
The original Python version was renamed to the _pyio module.
One minor resulting change: the io.TextIOBase class now has an errors attribute giving the error
setting used for encoding and decoding errors (one of ’strict’, ’replace’, ’ignore’).
The io.FileIO class now raises an OSError when passed an invalid file descriptor. (Implemented by
Benjamin Peterson; issue 4991.) The truncate() method now preserves the file position; previously it
would change the file position to the end of the new file. (Fixed by Pascal Chambon; issue 6939.)
• New function: itertools.compress(data, selectors) takes two iterators. Elements of data
are returned if the corresponding value in selectors is true:
itertools.compress(’ABCDEF’, [1,0,1,0,1,1]) =>
A, C, E, F
New function: itertools.combinations_with_replacement(iter, r) returns all the pos-
sible r-length combinations of elements from the iterable iter. Unlike combinations(), individual
elements can be repeated in the generated combinations:
itertools.combinations_with_replacement(’abc’, 2) =>
(’a’, ’a’), (’a’, ’b’), (’a’, ’c’),
(’b’, ’b’), (’b’, ’c’), (’c’, ’c’)
Note that elements are treated as unique depending on their position in the input, not their actual values.
The itertools.count() function now has a step argument that allows incrementing by values other
than 1. count() also now allows keyword arguments, and using non-integer values such as floats or
Decimal instances. (Implemented by Raymond Hettinger; issue 5032.)
itertools.combinations() and itertools.product() previously raised ValueError for
values of r larger than the input iterable. This was deemed a specification error, so they now return an empty
iterator. (Fixed by Raymond Hettinger; issue 4816.)
• Updated module: The json module was upgraded to version 2.0.9 of the simplejson package, which
includes a C extension that makes encoding and decoding faster. (Contributed by Bob Ippolito; issue 4136.)
To support the new collections.OrderedDict type, json.load() now has an optional ob-
ject_pairs_hook parameter that will be called with any object literal that decodes to a list of pairs. (Con-
tributed by Raymond Hettinger; issue 5381.)
• The mailbox module’s Maildir class now records the timestamp on the directories it reads, and only
re-reads them if the modification time has subsequently changed. This improves performance by avoiding
unneeded directory scans. (Fixed by A.M. Kuchling and Antoine Pitrou; issue 1607951, issue 6896.)
• New functions: the math module gained erf() and erfc() for the error function and the complemen-
tary error function, expm1() which computes e
**
x - 1 with more precision than using exp() and
subtracting 1, gamma() for the Gamma function, and lgamma() for the natural log of the Gamma func-
tion. (Contributed by Mark Dickinson and nirinA raseliarison; issue 3366.)
• The multiprocessing module’s Manager
*
classes can now be passed a callable that will be called
whenever a subprocess is started, along with a set of arguments that will be passed to the callable. (Con-
tributed by lekma; issue 5585.)
The Pool class, which controls a pool of worker processes, now has an optional maxtasksperchild param-
eter. Worker processes will perform the specified number of tasks and then exit, causing the Pool to start
a new worker. This is useful if tasks may leak memory or other resources, or if some tasks will cause the
worker to become very large. (Contributed by Charles Cazabon; issue 6963.)
• The nntplib module now supports IPv6 addresses. (Contributed by Derek Morr; issue 1664.)