[Python-Dev] SF patch 864863: Bisect C implementation
pedronis at bluewin.ch
Fri Jan 2 09:47:04 EST 2004
At 07:54 02.01.2004 -0600, Skip Montanaro wrote:
>If we are going to optimize standard library modules by implementing C
>counterparts but don't want the Python and C implementations to drift apart,
>we have to be able to test the Python versions somehow. Whatever that
>mechanism turns out to be has to be fairly convenient to use and shouldn't
>clutter up Python modules with checks solely used by the test framework.
I think that something like:
heapq python code...
from _heapq import * # or list the names explicitly
can be made to work.
The tricky part is more in test_heapq, but I think it can be rewritten in
some form like:
import heapq # import likely the C code
test(heapq) # or heapq could be a global
heapq = test.support.get_pure_python_version(heapq)
or some variation.
Assuming some conventions like _heapq/heapq etc,
get_pure_python_version would return a module not in sys.modules populated
just with the python code, basically tricking the last import momentarily
to fail. Barring some strange intermodule dependency issues which should
not be the case for this kind of modules this should be workable.
More information about the Python-Dev