Message153075
>> - 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). |
|
Date |
User |
Action |
Args |
2012-02-10 20:43:30 | ezio.melotti | set | recipients:
+ ezio.melotti, effbot, scoder, eric.araujo, eli.bendersky, flox |
2012-02-10 20:43:29 | ezio.melotti | set | messageid: <1328906609.99.0.242117228035.issue13988@psf.upfronthosting.co.za> |
2012-02-10 20:43:29 | ezio.melotti | link | issue13988 messages |
2012-02-10 20:43:29 | ezio.melotti | create | |
|