Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #94943

Re: how to determine for using c extension or not ?

Return-Path <umedoblock@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.010
X-Spam-Evidence '*H*': 0.98; '*S*': 0.00; 'correct.': 0.07; 'override': 0.07; 'cc:addr:python-list': 0.09; 'extension.': 0.09; 'subject:using': 0.09; 'python': 0.10; 'subject:not': 0.11; "skip:' 30": 0.15; '.dll': 0.16; 'bisect': 0.16; 'normal,': 0.16; 'received:192.168.11': 0.16; 'wrote:': 0.16; 'thanks.': 0.18; 'language': 0.19; '>>>': 0.20; 'windows': 0.20; '2015': 0.20; 'developer': 0.20; 'cc:2**0': 0.20; 'cc:addr:python.org': 0.20; 'aug': 0.20; 'extension': 0.20; '(on': 0.22; 'object.': 0.22; "skip:' 40": 0.22; 'sorry,': 0.22; 'cc:no real name:2**0': 0.22; 'am,': 0.23; 'this:': 0.23; 'import': 0.24; 'written': 0.24; 'header:In-Reply-To:1': 0.24; 'mon,': 0.24; 'module': 0.25; 'header:User-Agent:1': 0.26; "doesn't": 0.26; 'skip:" 20': 0.26; 'not.': 0.27; 'subject: ?': 0.27; 'question': 0.27; 'module.': 0.27; 'correct': 0.28; 'function': 0.28; 'sentence': 0.29; 'objects': 0.29; 'asked': 0.29; 'url:mailman': 0.30; 'skip:_ 10': 0.32; 'url:python': 0.33; "d'aprano": 0.33; 'everyone.': 0.33; 'steven': 0.33; 'message-id:@gmail.com': 0.34; 'url:listinfo': 0.34; 'members.': 0.34; 'file': 0.34; 'received:google.com': 0.35; 'world,': 0.35; 'question,': 0.35; 'asking': 0.35; 'but': 0.36; 'list,': 0.36; 'should': 0.36; 'url:org': 0.36; 'email addr:python.org': 0.36; 'pm,': 0.36; 'subject:: ': 0.37; 'two': 0.37; 'times.': 0.38; 'mailing': 0.38; 'means': 0.39; 'goes': 0.39; 'does': 0.39; 'received:192': 0.39; 'url:mail': 0.40; 'where': 0.40; 'your': 0.60; 'determine': 0.61; 'above,': 0.63; 'different': 0.63; 'believe': 0.66; 'python-list': 0.66; 'email name:python-list': 0.67; 'results.': 0.67; 'day': 0.67; 'answer.': 0.72; '2.7.': 0.84; 'answer,': 0.84; 'working,': 0.84; 'to:none': 0.91; 'joel': 0.91; 'sorry.': 0.91
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:date:from:user-agent:mime-version:cc:subject:references :in-reply-to:content-type:content-transfer-encoding; bh=eDHWw3aKxKIhES51UKdwquDDVuONIM9rh/QOoGar9s4=; b=tokbL+pSKvh4yGbA95yboZlXrx4RKbH8LFmd2QSLSZ/S7+n3KivqdRe0uNPvRiU7Q3 V5XBQGKfaGcJWkJ6bYuBxgG9iUyvi5RZn9AnD6/ufLNB1kuqL6WhbNCY/lWLjVbdXM+6 ZScE5984VBFUeOW1QvGztoCFJhVQgSQaiX5ZScKX6L1IDREkIlXlGNqFbEXMpiphhxN6 ZUZWMwF2OWKBkMwo+5xQfKVjEkLm4TjkrM7mlwYnYX6NMjg5of0oQYqV7wCakniPdfOM 4Qg4RSv4kZUspWKh3q08ooFrCSU74IpAyoMBXXCG8SHvwSz2W7si4qC93CGEizBHNJv1 O+5Q==
X-Received by 10.70.94.98 with SMTP id db2mr37179707pdb.130.1438613847543; Mon, 03 Aug 2015 07:57:27 -0700 (PDT)
Date Mon, 03 Aug 2015 23:57:24 +0900
From umedoblock <umedoblock@gmail.com>
User-Agent Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.8.0
MIME-Version 1.0
CC python-list@python.org
Subject Re: how to determine for using c extension or not ?
References <mailman.1170.1438580869.3674.python-list@python.org> <55bf6e6f$0$1650$c3e8da3$5496439d@news.astraweb.com> <55BF7457.8030704@gmail.com> <CAPM-O+wFC3jQzs6hzoK+PrypbYsubTwToVg43zjk_qPhR4T6fQ@mail.gmail.com>
In-Reply-To <CAPM-O+wFC3jQzs6hzoK+PrypbYsubTwToVg43zjk_qPhR4T6fQ@mail.gmail.com>
Content-Type text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding 8bit
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.20+
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.1193.1438613855.3674.python-list@python.org> (permalink)
Lines 104
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1438613855 news.xs4all.nl 2930 [2001:888:2000:d::a6]:56004
X-Complaints-To abuse@xs4all.nl
Path csiph.com!usenet.pasdenom.info!news.stben.net!border1.nntp.ams1.giganews.com!nntp.giganews.com!newsfeed.xs4all.nl!newsfeed8.news.xs4all.nl!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Xref csiph.com comp.lang.python:94943

Show key headers only | View raw


normal, no change
 >>> import bisect
 >>> bisect.bisect.__module__
'_bisect'

I change from "from _bisect import *" to "pass" in bisect.py

 >>> import bisect
 >>> bisect.bisect.__module__
'bisect'

bisect.bisect.__module__ return different results.
they are '_bisect' and 'bisect'.

I know that c extension document recomended us to use _ for c extension 
name  prefix.

I use "bisect.bisect.__module__" sentence to determine for using c 
extension or not.

thanks.

On 2015年08月03日 23:11, Joel Goldstick wrote:
> On Mon, Aug 3, 2015 at 10:01 AM, umedoblock <umedoblock@gmail.com> wrote:
>> sorry, Joel, Skip, Steven, and python-list members.
>>
>> I think that I don't sent my mail to python-list@python.org or I don't have
>> correct mail setting.
>>
>> so I send many mails.
>>
>> sorry... I should wait a day to get answer, sorry.
>>
>>
>> On 2015年08月03日 22:36, Steven D'Aprano wrote:
>>>
>>> On Mon, 3 Aug 2015 03:47 pm, umedoblock wrote:
>>>
>>>> Hello everyone.
>>>>
>>>> I use bisect module.
>>>
>>>
>>> You asked the same question FOUR times. Have patience. Your question goes
>>> all over the world, people may be asleep, or working, or just not know the
>>> answer. If you ask a question, and get no answers, you should wait a full
>>> day before asking again.
>>>
>>>
>>>> bisect module developer give us c extension as _bisect.
>>>>
>>>> If Python3.3 use _bisect, _bisect override his functions in bisect.py.
>>>
>>>
>>> So does Python 2.7.
>>>
>>>
>>>> now, I use id() function to determine for using c extension or not.
>>>
>>>
>>> The id() function doesn't tell you where objects come from or what
>>> language
>>> they are written in. But they will tell you if two objects are the same
>>> object.
>>>
>>>>>>> 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.
>>>
>>>
>>> Correct.
>>>
>>> Also, you can do this:
>>>
>>>
>>> py> import bisect
>>> py> bisect.__file__
>>> '/usr/local/lib/python2.7/bisect.pyc'
>>> py> bisect.bisect.__module__  # Where does the bisect file come from?
>>> '_bisect'
>>> py> import _bisect
>>> py> _bisect.__file__
>>> '/usr/local/lib/python2.7/lib-dynload/_bisect.so'
>>>
>>> So you can see that _bisect is a .so file (on Linux; on Windows it will be
>>> a .dll file), which means written in C.
>>>
>>>
>>
>> --
>> https://mail.python.org/mailman/listinfo/python-list
>
> Welcome to the mailing list, and as I see above, you got a good answer.
>

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

how to determine for using c extension or not ? umedoblock <umedoblock@gmail.com> - 2015-08-03 14:47 +0900
  Re: how to determine for using c extension or not ? Steven D'Aprano <steve@pearwood.info> - 2015-08-03 23:36 +1000
    Re: how to determine for using c extension or not ? umedoblock <umedoblock@gmail.com> - 2015-08-03 23:01 +0900
    Re: how to determine for using c extension or not ? Joel Goldstick <joel.goldstick@gmail.com> - 2015-08-03 10:11 -0400
    Re: how to determine for using c extension or not ? umedoblock <umedoblock@gmail.com> - 2015-08-03 23:57 +0900
    Re: how to determine for using c extension or not ? Oscar Benjamin <oscar.j.benjamin@gmail.com> - 2015-08-03 15:05 +0000
    Re: how to determine for using c extension or not ? umedoblock <umedoblock@gmail.com> - 2015-08-04 22:59 +0900

csiph-web