Ezio Melotti <[email protected]> added the comment:
>> - 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).
----------
nosy: +eric.araujo
_______________________________________
Python tracker <[email protected]>
<http://bugs.python.org/issue13988>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com