Author ezio.melotti
Recipients effbot, eli.bendersky, eric.araujo, ezio.melotti, flox, scoder
Date 2012-02-10.20:43:29
SpamBayes Score 1.5616e-08
Marked as misclassified No
Message-id <1328906609.99.0.242117228035.issue13988@psf.upfronthosting.co.za>
In-reply-to
Content
>>  - ElementTree: defines the python code and if _elementtree is 
>>  available overrides part of it with the functions imported from it;

> The problem with this is the bootstrap Python code executed by
_elementtree.

This might become unnecessary if ElementTree becomes the main module and _elementtree only contains a few faster functions/classes that are supposed to replace the ones written in Python.
So basically you only have a single fully functional Python module (ElementTree) plus an optional C module (_elementtree) that only provides faster replacements for ElementTree.

> That should not be executed when _elementtree (the C parts) can't be
> imported.

We are assuming that _elementtree might be missing, but what are the cases where this might actually happen? Other implementations like PyPy? Exotic platforms that can't compile _elementtree?

> Keeping this code in ElementTree will probably complicate 
> matters since it will add import conditions.

Wouldn't that as simple as having in ElementTree.py:
...
full python code here...
...
try:
    # override a few functions/classes with the faster versions
    from _elementtree import *
except ImportError:
    # _elementtree is missing, so we just keep the "slow" versions
    pass
else:
    # do the rest here if at all needed (e.g. plug the faster
    # versions in the right places)

I'm not familiar with ElementTree (I just looked at the bootstrap bit quickly), so what I'm saying might not be applicable here, but I've seen other modules doing something similar to what I'm proposing (json, heapq, maybe even warning and others).
History
Date User Action Args
2012-02-10 20:43:30ezio.melottisetrecipients: + ezio.melotti, effbot, scoder, eric.araujo, eli.bendersky, flox
2012-02-10 20:43:29ezio.melottisetmessageid: <1328906609.99.0.242117228035.issue13988@psf.upfronthosting.co.za>
2012-02-10 20:43:29ezio.melottilinkissue13988 messages
2012-02-10 20:43:29ezio.melotticreate