Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #78383
| Path | csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!news.stack.nl!newsfeed.xs4all.nl!newsfeed3a.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <ian.g.kelly@gmail.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.021 |
| X-Spam-Evidence | '*H*': 0.96; '*S*': 0.00; 'subject:Python': 0.06; 'attribute': 0.07; 'python': 0.11; "wouldn't": 0.14; 'attribute,': 0.16; 'attribute.': 0.16; 'callable': 0.16; 'meanwhile,': 0.16; 'subject: \n ': 0.16; 'subject: ?': 0.16; 'wrote:': 0.18; 'stefan': 0.19; '>>>': 0.22; 'either.': 0.24; 'header:In-Reply- To:1': 0.27; 'chris': 0.29; 'am,': 0.29; 'absolute': 0.30; 'strongly': 0.30; 'message-id:@mail.gmail.com': 0.30; "i'm": 0.30; 'code': 0.31; 'too.': 0.31; 'inspect': 0.31; 'sep': 0.31; 'running': 0.33; 'fri,': 0.33; 'implemented': 0.33; 'classes': 0.35; 'objects': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'there': 0.35; 'behind': 0.37; 'to:addr:python-list': 0.38; 'pm,': 0.38; 'sure': 0.39; 'to:addr:python.org': 0.39; 'enough': 0.39; 'times': 0.62; '26,': 0.68; 'certain,': 0.84; 'inexpensive': 0.84; 'subject:tell': 0.84 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type; bh=Cm0P6gMITDlwAbjOUYsSh/hBq8m4rD2Vtn/hYyI7Skw=; b=LfgAITXr4QA4EdZEHzLFlyNS9EkqgMs3TJl+vck61mQUQfqH5tngAQ1RnK3VXpDWpL cfhat/vx8CLKEOqHkqIdEP5hLxpeusET7JVq2gUYWYnpMKCSQLX+GwAfioc7Fb1I2kim DMoqAZIGcTOIEDs7Z1LbBw/quCt4e86HaGDpfCBwn01Bc6mGF4SzECSUn7X8tiNvjIkl enSLdljZlOmPK1YBGdqmCv86gNh91vqfKQWyBBCnKRfW8ybHM15ipthIrHgSPBMqDUEH x3hBY5iWeaHJg/P0H1i/4pbkZYVfjo8ZELkG3EiXlHIEt162gN+06p9uYx6wGYeZlqum rjOQ== |
| X-Received | by 10.69.18.203 with SMTP id go11mr23457296pbd.145.1411747859950; Fri, 26 Sep 2014 09:10:59 -0700 (PDT) |
| MIME-Version | 1.0 |
| In-Reply-To | <m03l7b$umb$1@ger.gmane.org> |
| References | <m035kl$54v$1@ger.gmane.org> <CAPTjJmpg1LkHk4FDSQX30Tusdw_9=+iVUDXyntLN1TVrbX4U7g@mail.gmail.com> <m03l7b$umb$1@ger.gmane.org> |
| From | Ian Kelly <ian.g.kelly@gmail.com> |
| Date | Fri, 26 Sep 2014 10:10:19 -0600 |
| Subject | Re: any way to tell at runtime whether a callable is implemented in Python or C ? |
| To | Python <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.14398.1411747869.18130.python-list@python.org> (permalink) |
| Lines | 17 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1411747869 news.xs4all.nl 2926 [2001:888:2000:d::a6]:40426 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:78383 |
Show key headers only | View raw
On Fri, Sep 26, 2014 at 6:12 AM, Stefan Behnel <stefan_ml@behnel.de> wrote: > Chris Angelico schrieb am 26.09.2014 um 10:42: >> On Fri, Sep 26, 2014 at 5:47 PM, Wolfgang Maier wrote: >>> 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. > > Cython implemented native functions have a "__code__" attribute, too. Their > current "__code__.co_code" attribute is empty (no bytecode), but I wouldn't > rely on that for all times either. Meanwhile, Python classes and objects with __call__ methods have no __code__ attribute.
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: any way to tell at runtime whether a callable is implemented in Python or C ? Ian Kelly <ian.g.kelly@gmail.com> - 2014-09-26 10:10 -0600
csiph-web