how to determine for using c extension or not ?
tjreedy at udel.edu
Mon Aug 3 20:11:27 CEST 2015
On 8/3/2015 9:08 AM, umedoblock wrote:
Posting three times under two different names is not polite. Please to
> 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
from _bisect import *
For CPython, I expect that all 4 similar functions (and two synonyms)
> 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
>>>> import bisect
>>>> import _bisect
> 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