[The HTML version of this Summary is available at http://www.python.org/dev/summary/2005-06-16_2005-06-30.html]

Summary Announcements

OSCON Registration

Though if you haven't yet registered, you've already missed the early registration period (which ended June 20), you should still consider taking a look at the O'Reilly Open Source Convention (OSCON). Guido assures us that "the Python program is really good!"

Contributing Thread:


PEP Clean Up

Raymond Hettinger decided to go through the list of PEPs and do some spring cleaning (late for the Northern Hemisphere, but early down south).

  • Rejection of PEP 303 ("Extend divmod() for Multiple Divisors") was proposed on the grounds that it has been open for two and half years and hasn't generated discussion or support, is unpersuasive, and unnecessary. No-one spoke up for it (and some against), so it is now rejected.
  • Rejection of PEP 254 ("Making Classes Look More Like Types") was proposed on the grounds that it is only an empty stub and is unlikely to ever get filled-out. No-one spoke up either way, and it is now rejected.
  • Rejection of PEP 265 ("Sorting Dictionaries by Value") was proposed on the grounds that as of Python 2.4 its use case is easily solved with a one-line sorted() solution. Several people agreed, and no-one disagreed, so the PEP is now rejcted.
  • Rejection of PEP 276 ("Simple iterator for ints") was proposed on the grounds that the principal use case was largely met by enumerate() and that the proposed syntax was problematic. Guido agreed, so the PEP was rejected.
  • Rejection of PEP 281 ("Loop Counter Iteration with range and xrange") was proposed on the grounds that it too was solved by the enumerate() built-in. Guido agreed again, and this PEP too was rejected.
  • Rejection of PEP 294 ("Type Names in the types Module") was proposed on the grounds that a centralized repository of type names was a mistake and that neither the "types" nor "new" modules should be carried forward to Python 3.0. No-one disagreed, and the PEP was rejected.
  • Rejection of PEP 313 ("Adding Roman Numeral Literals to Python" - yes, this is a real PEP!) was proposed, and the PEP was rejected.
  • Rejection of PEP 336 ("Make None Callable") was proposed on the grounds that no support has grown beyond the original poster, and that it fails the tests of obviousness, necessity, clarity, and explicitness. Many people, including Guido, agreed, and the PEP was rejected.
  • Raymond suggested updating PEP 284 ("Integer for-loops"), but several people spoke up against it, including Guido, so the PEP was rejected.
  • Raymond asked whether PEP 330 ("Python Bytecode Verification") had any known uses. Guido said that he believes that a verification tool has some value, but if someone wants to add it to Tools/scripts, no PEP is required, so the PEP was rejected.
  • A.M. Kuchling volunteered to take over PEP 206 ("Python Advanced Library", or the "Batteries Included" PEP) and rewrite it to describe a set of third-party packages to complement the standard library. This was approved, and so he's now the maintainer.
  • Raymond suggested accepting PEP 312 ("Simple Implicit Lambda"), which resulted in the most discussion of any of the PEP recommendations. However, Guido hates the unary colon syntax, and it was decided that the PEP needs to go back to the drawing board and find a more Pythonic syntax (perhaps an alternative unary operator). The PEP is now deferred.
  • Raymond asked whether PEP 237 ("Unifying Long Integers and Integers") was now complete and could be marked as final. Guido noted that it was complete for 2.x, but that phase C will be implemented in Python 3.0, as the PEP states. He indicated that he would be fine with marking PEP 237 as final and moving this phase to PEP 3000; at the time of writing, this hadn't been done yet.

Contributing Threads:


PEP 342: Coroutines via Enhanced Generators

Raymond Hettinger withdrew PEP 288, since the exception-handling part is now covered in PEP 343 and the generator-attributes part was never very popular. Though he seemed to think PEP 342 could replace the generator-attributes part, he was concerned that PEP 342 was proposing too extensive a set of changes, as it modified the basic for-loop and continue statement semantics, and created a split between new- and old-style iterators. As a result of those comments, Phillip J. Eby took over PEP 342, eliminated the continue expression and modification of the for-loop, added some motivating examples, and provided a prototype patch implementing the proposal. PEP 342 now retains normal Python for-loop and continue statements, and does not introduce a new iterator protocol. Instead, it modifies the generator-iterator type by adding the methods:

  • send(value) which acts like the previously proposed single-argument form of next(). (Introducing a new method instead of overloading next() minimizes overhead for simple next() calls.) Calling send(value) before the generator has advanced to the first yield-expression raises a TypeError.
  • throw() which injects exceptions at the point of the generator's last yield-expression.
  • close() which injects a GeneratorExit exception into the generator to make sure that it terminates. PEP 342 also attempts to ensure that this close() method will be called when a generator-iterator is garbage-collected.

Additionally, Phillip's patch addressed some garbage collection issues, having generators set their gi_frame to None when they finish, and modifying gcmodule.c to check for tp_del methods on instance objects (instead of just on heap types) so that the close() methods of generators would be properly invoked.

The revised PEP was accepted by Guido at EuroPython.

Contributing Threads:


Adding Jason Ordenorff's path module to the stdlib

Reinhold Birkenfeld suggested that Jason Ordenorff's path module should be in the standard library as it has a large user base, frequently c.l.py praises, is a superior interface to OS paths than the existing os.path module, and could more easily be made to properly support unicode paths. Phillip J. Eby reviewed the module and made a list of suggested changes, primarily changing so that there is only one way to do things and clearing up naming confusion between the module and the existing os.path module, but was generally in favour of inclusion. The suggestion was to call the object either "path" or "Path" and put it either in the os module or os.path module, although Guido vetoed os.path.path and Tony Meyer begged for more differentiation between the path class and path module than a single character's case.

Early enthusiasm suggested that a PEP wasn't needed to include the module, as there was general agreement about the inclusion and all but minor details. Guido disagreed, however, asking whether there was a need for a completely different mechanism for doing the same things that os.path already does, and inevitable disgreements about details (e.g. time in seconds, or a datetime object?) reinforced the need for a PEP. Discussion was still continuing at the end of the summary period; a PEP seems the likely outcome.

Contributing Thread:


PEP 304 searches for a champion

Skip Montanaro wrote PEP 304 ("Controlling Generation of Bytecode Files") a couple of years ago, and has mostly sat idle other than minor updates. Skip has no personal use for the PEP, and can't offer championing for it than continuing to respond to people's inputs. He asked whether anyone would be willing to take up championship of the PEP, or if it could be rejected. There were a couple of people interested in the idea, but no-one has yet volunteered to take the PEP from Skip.

Contributing Threads:


Merging float and Decimal

Fredrik Johansson suggested that Python floats and decimal.Decimal objects should be merged together much in the way that Python ints and longs have been. The idea would be that a binary or decimal represenation could be selected at runtime using a context object like decimal.Context. This would allow code like:

>>> from __future__ import new_float_behaviour
>>> 1.1
>>> import sys
>>> sys.float_context.binary = True
>>> 1.1

One issue would be the extent to which various context settings could be respected for both binary and decimal floating-point numbers. Since binary floating-point numbers would be represented using C floats, they would not have direct access to the traps and flags that decimal.Decimal floats do because these signals are not available in C. This issue could possibly be addressed by maintaining platform-dependent code for accessing traps and flags.

People seemed generally to agree with the proposal, with Raymond Hettinger suggesting a roadmap: first move decimal.Decimal objects to C code, next introduce decimal literals such as 123.45d, and then perhaps use decimal floating-point numbers as the default in Python 3.0.

Contributing Thread:


API differences between builtin set and sets.Set

Barry Warsaw noted that builtin set objects (unlike sets.Set objects) do not have .union_update() methods as aliases for their .update() methods. He also pointed out that the documentation for builtin set objects does not cover the .update() method, and wrongly indicates that the set methods only accept sequences, not iterables.

Raymond Hettinger pointed-out that dropping union_update() from the API was an intentional design decision that was be discussed prior to release. At Barry's suggestion, Raymond expanded the docs to include a detailed list of differences between the set builtins and the sets module. The list is thankfully short.

Contributing Thread:


Using the alternate form of iter()

In the dowhile threads, Jp Calderone pointed out a useful case for the alternate form of iter() which takes a no-argument function to call repeatedly, and a sentinel value to look for:

for chunk in iter(lambda: f1.read(CHUNK_SIZE), ''):

This started a brief discussion on how this very useful idiom could be made easier to read. I suggested that it would be nice if iter() had a signature like unittest.TestCase.assertRaises which accepts *args and **kwargs to be passed to the function when it is called. This would have to be a Python 3.0 change because it's backwards incompatible, but would look something like:

for chunk in iter('', f1.read, CHUNK_SIZE):

Benji York, Michael Hudson and James Y Knight suggested that functional.partial (which will be available in Python 2.5) is a more general solution because it does not require argument reordering and it can also be used in the occasional cases that require multiple callables:

for chunk in iter(partial(f1.read, CHUNK_SIZE), ''):

Raymond Hettinger suggested a Python 3.0 roadmap: the file API should evolve an iterblocks(size) method, and iteration patterns terminating with '' should all be replaced with modern iterators that terminate by raising StopIteration.

Contributing Thread:


Adding lightweight cooperative threads

Adam Olsen outlined various problems with the current state of Python threading (they are expensive, unpredictable, uninterupptible, fail silently, and have finely grained atomicity), and proposed adding lightweight cooperative threads to Python (including a new operator for threaded calls, and new statement for creating threads). The proposal received no support, however, with Adam pointed towards Stackless Python and greenlets from the Py lib as similar solutions that do not require modification of the language. PEP 342 was also touted as a solution - the PEP includes a short (<50 lines) cooperative threading example.

Contributing Thread:


Syntax for ignoring exceptions

Dmitry Dvoinikov proposed a shorthand for ignoring exceptions:

ignore TypeError:
    do stuff
    do other stuff]

which would replace:

    do stuff
except TypeError:
    do other stuff]

Most people seemed to think that generally the except and/or else clauses would be non-trivial, so the savings of two lines were not really worth the complications to the language.

Contributing Thread:


Proposed new serialization format.

Simon Wittber proposed a pre-PEP for RFE 46738, to provide a safe, documented class for serialization of simple python types; however, many people commented that they felt that there were already sufficient serialization formats. Simon felt that they were all slow, bloated or unsafe, but wasn't able to convince anyone that there was a need for a new format.

Contributing Thread:


Behavior of subprocess.call(stdin=PIPE)

In a followup to a sourceforge patch, Stuart Bishop asked that subprocess.call() close the input stream if it receives the keyword argument stdin=PIPE. Since subprocess.call() creates a process and waits for it to complete before returning, the stdin pipe is never available to the caller and thus can never be written to while the process is running. Stuart suggested that if subprocess.call() closed the input stream when stdin=PIPE, subprocesses that incorrectly read from stdin would break out with an error immediately instead of hanging.

While people seemed to agree that the current behavior of subprocess.call(stdin=PIPE) was mildly undesirable, there was disagreement as to the solution. Michael Chermside suggested that subprocess.call(stdin=PIPE) should raise an exception, while Peter Åstrand felt that keeping the subprocess.call() wrapper around subprocess.Popen() as simple as possible spoke against complicating it with error checking code.

Contributing Thread:




This is a summary of traffic on the python-dev mailing list from June 16, 2005 through June 30, 2005.

It is intended to inform the wider Python community of on-going developments on the list on a semi-monthly basis. An archive of previous summaries is available online.

An RSS feed of the titles of the summaries is available. You can also watch comp.lang.python or comp.lang.python.announce for new summaries (or through their email gateways of python-list or python-announce, respectively, as found at http://mail.python.org).

This is the sixth summary written by the python-dev summary cabal of Steve Bethard, Tim Lesher, and Tony Meyer.

To contact us, please send email:

  • Steve Bethard (steven.bethard at gmail.com)
  • Tim Lesher (tlesher at gmail.com)
  • Tony Meyer (tony.meyer at gmail.com)

Do not post to comp.lang.python if you wish to reach us.

The Python Software Foundation is the non-profit organization that holds the intellectual property for Python. It also tries to advance the development and use of Python. If you find the python-dev Summary helpful please consider making a donation. You can make a donation at http://python.org/psf/donations.html . Every penny helps so even a small donation with a credit card, check, or by PayPal helps.

Commenting on Topics

To comment on anything mentioned here, just post to comp.lang.python (or email python-list at python.org which is a gateway to the newsgroup) with a subject line mentioning what you are discussing. All python-dev members are interested in seeing ideas discussed by the community, so don't hesitate to take a stance on something. And if all of this really interests you then get involved and join python-dev!

How to Read the Summaries

The in-development version of the documentation for Python can be found at http://www.python.org/dev/doc/devel/ and should be used when looking up any documentation for new code; otherwise use the current documentation as found at http://docs.python.org/ . PEPs (Python Enhancement Proposals) are located at http://www.python.org/peps/ . To view files in the Python CVS online, go to http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/python/ . Reported bugs and suggested patches can be found at the SourceForge project page.

Please note that this summary is written using reStructuredText. Any unfamiliar punctuation is probably markup for reST (otherwise it is probably regular expression syntax or a typo =); you can safely ignore it. I do suggest learning reST, though; it's simple and is accepted for PEP markup and can be turned into many different formats like HTML and LaTeX. Unfortunately, even though reST is standardized, the wonders of programs that like to reformat text do not allow me to guarantee you will be able to run the text version of this summary through Docutils as-is unless it is from the original text file.