[Python-Dev] folding cElementTree behind ElementTree in 3.3
eliben at gmail.com
Wed Feb 8 04:59:21 CET 2012
Here's a note from "What's new in Python 3.0":
"""A common pattern in Python 2.x is to have one version of a module
implemented in pure Python, with an optional accelerated version
implemented as a C extension; for example, pickle and cPickle. This
places the burden of importing the accelerated version and falling
back on the pure Python version on each user of these modules. In
Python 3.0, the accelerated versions are considered implementation
details of the pure Python versions. Users should always import the
standard version, which attempts to import the accelerated version and
falls back to the pure Python version. The pickle / cPickle pair
received this treatment. The profile module is on the list for 3.1.
The StringIO module has been turned into a class in the io module."""
Is there a good reason why xml.etree.ElementTree /
xml.etree.cElementTree did not "receive this treatment"?
In the case of this module, it's quite unfortunate because:
1. The accelerated module is much faster and memory efficient (see
recent benchmarks here: http://bugs.python.org/issue11379), and XML
processing is an area where processing matters
2. The accelerated module implements the same API
3. It's very hard to even find out about the existence of the
accelerated module. Its sole mention in the docs is this un-emphasized
line in http://docs.python.org/dev/py3k/library/xml.etree.elementtree.html:
"A C implementation of this API is available as xml.etree.cElementTree."
Even to an experienced user who carefully reads the whole
documentation it's not easy to notice. For the typical user who just
jumps around to functions/methods he's interested in, it's essentially
More information about the Python-Dev