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


Groups > comp.lang.python > #78373

Re: any way to tell at runtime whether a callable is implemented in Python or C ?

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <rosuav@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.029
X-Spam-Evidence '*H*': 0.94; '*S*': 0.00; 'subject:Python': 0.06; 'attribute': 0.07; 'cc:addr:python-list': 0.11; 'python': 0.11; 'callable': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'subject: \n ': 0.16; 'subject: ?': 0.16; 'wrote:': 0.18; 'cc:addr:python.org': 0.22; 'cc:2**0': 0.24; 'header:In-Reply-To:1': 0.27; 'absolute': 0.30; 'strongly': 0.30; 'message-id:@mail.gmail.com': 0.30; "i'm": 0.30; 'code': 0.31; 'inspect': 0.31; 'sep': 0.31; 'running': 0.33; 'fri,': 0.33; 'implemented': 0.33; 'but': 0.35; 'received:google.com': 0.35; 'there': 0.35; 'hi,': 0.36; 'behind': 0.37; 'pm,': 0.38; 'sure': 0.39; 'enough': 0.39; '26,': 0.68; 'certain,': 0.84; 'inexpensive': 0.84; 'subject:tell': 0.84; 'to:none': 0.92
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:cc :content-type; bh=KcS7vku/WMBifJc2qsYyElCG/RbVbosIpIvo5i5ASDg=; b=HDGeHRZpuIxWLiP1P+y3SBQDuNgZu7iwFR0ZDybjqboYQsDG6JoCiKbVyARHUVwQWw ZLJbrVUi2FvOHpaERosq/fEfhu0yxBiuWxsjnH685XZiJ7lU2y0giHG28JHRDicopV8X YzR3XbiCobJ7lyqqvvBawhRHrYkfDC/6YDsZ+Xq4mvmNjgxXk+xVBjYkfiHntnYzakBI O+JBG1HhiYrAH2ppFXNTtQNKud/n0g3FiRs5rA22DiSb0Zko2u26t84rk0Txcb8LZpMb 0YDsUzSPUG22ojLcdOj9Ymzd13WLUdsE4DzQ14ROTdw7ajUVdb2Satd9VVPFirr+V3ax xrSA==
MIME-Version 1.0
X-Received by 10.43.94.7 with SMTP id bw7mr23064393icc.26.1411720960008; Fri, 26 Sep 2014 01:42:40 -0700 (PDT)
In-Reply-To <m035kl$54v$1@ger.gmane.org>
References <m035kl$54v$1@ger.gmane.org>
Date Fri, 26 Sep 2014 18:42:39 +1000
Subject Re: any way to tell at runtime whether a callable is implemented in Python or C ?
From Chris Angelico <rosuav@gmail.com>
Cc "python-list@python.org" <python-list@python.org>
Content-Type text/plain; charset=UTF-8
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
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.14389.1411720962.18130.python-list@python.org> (permalink)
Lines 12
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1411720962 news.xs4all.nl 2906 [2001:888:2000:d::a6]:55591
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:78373

Show key headers only | View raw


On Fri, Sep 26, 2014 at 5:47 PM, Wolfgang Maier
<wolfgang.maier@biologie.uni-freiburg.de> wrote:
> Hi,
> is there any reliable and inexpensive way to inspect a callable from running
> Python code to learn whether it is implemented in Python or C before calling
> into it ?

I'm not sure you can say for absolute certain, but the presence of a
__code__ attribute is strongly suggestive that there's Python code
behind the function. That might be good enough for your purposes.

ChrisA

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


Thread

Re: any way to tell at runtime whether a callable is implemented in Python or C ? Chris Angelico <rosuav@gmail.com> - 2014-09-26 18:42 +1000

csiph-web