Movatterモバイル変換


[0]ホーム

URL:


[Python-Dev] folding cElementTree behind ElementTree in 3.3

Eli Benderskyeliben at gmail.com
Wed Feb 8 04:59:21 CET 2012


Hello,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 moduleimplemented in pure Python, with an optional accelerated versionimplemented as a C extension; for example, pickle and cPickle. Thisplaces the burden of importing the accelerated version and fallingback on the pure Python version on each user of these modules. InPython 3.0, the accelerated versions are considered implementationdetails of the pure Python versions. Users should always import thestandard version, which attempts to import the accelerated version andfalls back to the pure Python version. The pickle / cPickle pairreceived 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 (seerecent benchmarks here:http://bugs.python.org/issue11379), and XMLprocessing is an area where processing matters2. The accelerated module implements the same API3. It's very hard to even find out about the existence of theaccelerated module. Its sole mention in the docs is this un-emphasizedline inhttp://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 wholedocumentation it's not easy to notice. For the typical user who justjumps around to functions/methods he's interested in, it's essentiallyinvisible.Eli


More information about the Python-Devmailing list

[8]ページ先頭

©2009-2025 Movatter.jp