how to determine for using c extension or not ?
Terry Reedy
tjreedy at udel.edu
Mon Aug 3 14:11:27 EDT 2015
On 8/3/2015 9:08 AM, umedoblock wrote:
Posting three times under two different names is not polite. Please to
not repeat.
> I use bisect module.
> bisect module developer give us c extension as _bisect.
We call that a C accelerator.
> If Python3.3 use _bisect, _bisect override his functions in bisect.py.
An accelerator may override either some or all functions.
In this case, Lib/bisect.py ends with
try:
from _bisect import *
except ImportError:
pass
For CPython, I expect that all 4 similar functions (and two synonyms)
get replaced.
> now, I use id() function to determine for using c extension or not.
You should not care. If you think there is an undocumented difference
in behavior, ask here if it is a bug.
I expect that that test/test_bisect.py runs the same tests on both
versions. We have a test helper function for such situations. It
blocks the import of the accelerator so that the Python version can be
tested.
>>>> import bisect
>>>> id(bisect.bisect)
> 139679893708880
>>>> import _bisect
>>>> id(_bisect.bisect)
> 139679893708880
>
> they return 139679893708880 as id.
> so i believe that i use c extension.
The bisect and _bisect modules are different objects. Since they and
their global namespace exist simultaneously, then yes, the above says
that both have the name 'bisect' bound to the C-coded built-in version.
--
Terry Jan Reedy
More information about the Python-list
mailing list