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


Groups > comp.lang.python > #94918 > unrolled thread

how to determine for using c extension or not ?

Started byumedoblock <umedoblock@gmail.com>
First post2015-08-03 14:47 +0900
Last post2015-08-04 22:59 +0900
Articles 7 — 4 participants

Back to article view | Back to comp.lang.python


Contents

  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

#94918 — how to determine for using c extension or not ?

Fromumedoblock <umedoblock@gmail.com>
Date2015-08-03 14:47 +0900
Subjecthow to determine for using c extension or not ?
Message-ID<mailman.1170.1438580869.3674.python-list@python.org>
Hello everyone.

I use bisect module.
bisect module developer give us c extension as _bisect.

If Python3.3 use _bisect, _bisect override his functions in bisect.py.

now, I use id() function to determine for using c extension or not.

>>> 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.

My check is correct ? right ?
or you have more good idea ?

[toc] | [next] | [standalone]


#94935

FromSteven D'Aprano <steve@pearwood.info>
Date2015-08-03 23:36 +1000
Message-ID<55bf6e6f$0$1650$c3e8da3$5496439d@news.astraweb.com>
In reply to#94918
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.


-- 
Steven

[toc] | [prev] | [next] | [standalone]


#94938

Fromumedoblock <umedoblock@gmail.com>
Date2015-08-03 23:01 +0900
Message-ID<mailman.1188.1438610526.3674.python-list@python.org>
In reply to#94935
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.
>
>

[toc] | [prev] | [next] | [standalone]


#94939

FromJoel Goldstick <joel.goldstick@gmail.com>
Date2015-08-03 10:11 -0400
Message-ID<mailman.1189.1438611099.3674.python-list@python.org>
In reply to#94935
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.

-- 
Joel Goldstick
http://joelgoldstick.com

[toc] | [prev] | [next] | [standalone]


#94943

Fromumedoblock <umedoblock@gmail.com>
Date2015-08-03 23:57 +0900
Message-ID<mailman.1193.1438613855.3674.python-list@python.org>
In reply to#94935
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.
>

[toc] | [prev] | [next] | [standalone]


#94946

FromOscar Benjamin <oscar.j.benjamin@gmail.com>
Date2015-08-03 15:05 +0000
Message-ID<mailman.1194.1438614314.3674.python-list@python.org>
In reply to#94935

[Multipart message — attachments visible in raw view] — view raw

On Mon, 3 Aug 2015 at 15:58 umedoblock <umedoblock@gmail.com> wrote:

>
> I use "bisect.bisect.__module__" sentence to determine for using c
> extension or not.
>
>
Why do you want to know if it uses the C extension? It shouldn't really
matter.

--
Oscar

[toc] | [prev] | [next] | [standalone]


#94965

Fromumedoblock <umedoblock@gmail.com>
Date2015-08-04 22:59 +0900
Message-ID<mailman.1214.1438696775.3674.python-list@python.org>
In reply to#94935
On 2015年08月04日 00:05, Oscar Benjamin wrote:
> On Mon, 3 Aug 2015 at 15:58 umedoblock <umedoblock@gmail.com
> <mailto:umedoblock@gmail.com>> wrote:
>
>
>     I use "bisect.bisect.__module__" sentence to determine for using c
>     extension or not.
>
>
> Why do you want to know if it uses the C extension? It shouldn't really
> matter.

I wrote some C accelerator.
I sometimes want to know that python3.x in another machine use C 
accelerator or not.

Because if python3.x doesn't use C acc, I shuold make C acc for another 
machine.
Therefore I'd like to determine for using C acc or not.
And I want to know that another machine use C acc or not to use a simple 
script.

But I had felt not good idea about my way to use id().
So I ask this mailing list.

>
> --
> Oscar

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web