Path: csiph.com!usenet.pasdenom.info!news.redatomik.org!newsfeed.xs4all.nl!newsfeed8.news.xs4all.nl!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.000 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'importerror:': 0.05; 'bug.': 0.07; 'override': 0.07; 'versions.': 0.07; 'accelerator': 0.09; 'behavior,': 0.09; 'extension.': 0.09; 'namespace': 0.09; 'objects.': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'subject:using': 0.09; 'undocumented': 0.09; 'python': 0.10; 'jan': 0.11; 'subject:not': 0.11; 'bisect': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'reedy': 0.16; 'replaced.': 0.16; 'wrote:': 0.16; 'helper': 0.18; 'try:': 0.18; 'version.': 0.18; 'tests': 0.18; 'runs': 0.18; 'developer': 0.20; 'extension': 0.20; 'pass': 0.22; 'am,': 0.23; 'import': 0.24; 'header:In-Reply-To:1': 0.24; 'module': 0.25; 'header:User-Agent:1': 0.26; 'header:X-Complaints-To:1': 0.26; 'not.': 0.27; 'subject: ?': 0.27; 'module.': 0.27; 'function': 0.28; 'posting': 0.32; 'says': 0.32; 'similar': 0.33; 'case,': 0.34; 'except': 0.34; 'exist': 0.35; 'functions.': 0.35; 'should': 0.36; 'there': 0.36; '(and': 0.36; 'modules': 0.36; 'to:addr :python-list': 0.36; 'subject:: ': 0.37; 'two': 0.37; 'expect': 0.37; 'received:org': 0.37; 'difference': 0.38; 'version': 0.38; 'names': 0.38; 'test': 0.39; 'to:addr:python.org': 0.40; 'some': 0.40; 'determine': 0.61; 'different': 0.63; 'times': 0.63; 'believe': 0.66; 'here': 0.66; 'repeat.': 0.84; 'received:fios.verizon.net': 0.91 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Terry Reedy Subject: Re: how to determine for using c extension or not ? Date: Mon, 3 Aug 2015 14:11:27 -0400 References: <55BF67CB.5030604@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Gmane-NNTP-Posting-Host: pool-98-114-97-173.phlapa.fios.verizon.net User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.1.0 In-Reply-To: <55BF67CB.5030604@gmail.com> X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.20+ Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 50 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1438625504 news.xs4all.nl 2934 [2001:888:2000:d::a6]:36380 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:94952 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