[Python-Dev] Sharing expat instances
Brett Cannon
bcannon at gmail.com
Wed Dec 14 00:18:24 CET 2005
On 12/13/05, Fredrik Lundh <fredrik at pythonware.com> wrote:
> I wrote:
>
> > 1. add an Include/pyexpat.h header file which contains a structure
> > similar to the following:
>
> > 2. during pyexpat initialization, initialize all members of this structure, and
> > make it available as a PyCObject:
>
> > 3. in cElementTree (or _elementtree, or whatever the python version will
> > be named), import pyexpat, fetch the object, and verify
>
> > 4. in cElementTree (...), do all expat calls via the dispatch table.
>
> I've fixed all this, and checked in 1 and 2.
>
> 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 ?
>
Too bad you can't do 1 and for 2 add ``import _elementtree as
cElementTree`` in etree/__init__.py . Unless I am missing something
it won't work since ``import xml.etree.cElementTree`` will fail.
Since the way you outlined is the standard way to do it in the stdlib
I doubt anyone has thought of a better way.
-Brett
More information about the Python-Dev
mailing list