[Python-Dev] Sharing expat instances

Michael McLay mmclay at comcast.net
Wed Dec 14 04:18:12 CET 2005


On Tuesday 13 December 2005 17:17, Fredrik Lundh wrote:
> the remaining issue is how to include cElementTree.  the current stand-
> alone distribution consists of a single cElementTree module, which is in-
> stalled under site-packages, as usual.
>
> to avoid collisions, it's probably best to install the bundled version
> under xml.etree, but how do you do that for a C module ?
>
> my current idea is to
>
>     1.  include it under a different name (_elementtree.so)
>
>     2.  add a cElementTree.py under xml.etree, which simply does
>
>             from _elementtree import *
>
> does anyone have a better idea ?

Avoiding imaginaary name collisions and putting cElementTree into the xml 
package is making the task harder than need be and will perpetuate the 
problems caused by the earlier decision to do magic in the xml import 
statement. The use of magic was a violation of "explicit is better than 
implicit". Forgeting this rule has caused pain to many people who didn't 
expect a magic side effects from simply installing PyXML. Adding cElementTree 
to the mess that already exists doessn't make sense, and the only 
justification for not adding a new top level package seems to be to avoid an 
imaginary potential for name collisions. 

Why repeat the mistake of PyXML simply to have all the xml software in the 
same top level package? Perhaps if this were a common practice in the stdlib 
it might make sense. For instance, if there were a gui.Tkinter and a 
gui.PyGtk and a gui.wxPython it might look more consistent. Who is pushing to 
put all xml software inside the xml package?  Collisions with names of a top 
level import statement are rare and Python has supports renaming in the rare 
event that someone did need to rename the module.

 import etree as stdetree.

I would like the cElementTree version of the package have a shorter name. For 
example etree. The Python implementation could continue to be named 
ElementTree or shorten it to pyetree. The cElementTree version will probably 
be the most frequently used since it is faster, so why not make it's name 
short.

One final addition would be to include a "See Also" reference to the new etree 
and pyetree modules in the introduction of the xml package.



More information about the Python-Dev mailing list