Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #40004
| Path | csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.freenet.ag!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <ethan@stoneleaf.us> |
| 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; 'heavily': 0.04; 'except:': 0.07; 'layers': 0.07; 'try:': 0.07; 'python': 0.09; 'assigning': 0.09; 'from:addr:ethan': 0.09; 'from:addr:stoneleaf.us': 0.09; 'from:name:ethan furman': 0.09; 'happen?': 0.09; 'message- id:@stoneleaf.us': 0.09; 'received:184.172': 0.09; 'received:gator410.hostgator.com': 0.09; 'subject:into': 0.09; 'subject:method': 0.09; '~ethan~': 0.09; 'def': 0.10; 'subject:python': 0.11; 'extension': 0.13; 'a():': 0.16; 'py3': 0.16; 'subject: \n ': 0.16; 'subject:class': 0.16; 'unbound': 0.16; 'wrote:': 0.17; 'module': 0.19; 'import': 0.21; 'subject:problem': 0.22; 'work.': 0.23; 'pass': 0.25; 'tried': 0.25; 'header:In-Reply-To:1': 0.25; 'header:User-Agent:1': 0.26; 'am,': 0.27; "doesn't": 0.28; 'all.': 0.28; 'fine': 0.28; 'methods.': 0.29; 'class': 0.29; 'stuff': 0.30; 'to:addr:python- list': 0.33; 'there': 0.35; 'but': 0.36; 'method': 0.36; 'subject:: ': 0.38; 'fact': 0.38; 'some': 0.38; 'to:addr:python.org': 0.39; 'called': 0.39; 'header:Received:5': 0.40; 'times': 0.63; 'our': 0.65; 'received:67.18': 0.65; 'skip:n 30': 0.69; '.....': 0.75; 'dumb': 0.84; 'forward.': 0.84; 'received:gateway14.websitewelcome.com': 0.91 |
| Date | Tue, 26 Feb 2013 12:19:14 -0800 |
| From | Ethan Furman <ethan@stoneleaf.us> |
| User-Agent | Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130106 Thunderbird/17.0.2 |
| MIME-Version | 1.0 |
| To | python-list@python.org |
| Subject | Re: python 3 problem: how to convert an extension method into a class Method |
| References | <512CEF0C.3020906@chamonix.reportlab.co.uk> |
| In-Reply-To | <512CEF0C.3020906@chamonix.reportlab.co.uk> |
| Content-Type | text/plain; charset=ISO-8859-1; format=flowed |
| Content-Transfer-Encoding | 7bit |
| X-AntiAbuse | This header was added to track abuse, please include it with any abuse report |
| X-AntiAbuse | Primary Hostname - gator410.hostgator.com |
| X-AntiAbuse | Original Domain - python.org |
| X-AntiAbuse | Originator/Caller UID/GID - [47 12] / [47 12] |
| X-AntiAbuse | Sender Address Domain - stoneleaf.us |
| X-BWhitelist | yes |
| X-Source | |
| X-Source-Args | |
| X-Source-Dir | |
| X-Source-Sender | ([173.12.184.235]) [173.12.184.235]:35028 |
| X-Source-Auth | ethan+stoneleaf.us |
| X-Email-Count | 3 |
| X-Source-Cap | dG9idWs7dG9idWs7Z2F0b3I0MTAuaG9zdGdhdG9yLmNvbQ== |
| 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 | <http://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 | <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.2574.1361911052.2939.python-list@python.org> (permalink) |
| Lines | 38 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1361911052 news.xs4all.nl 6884 [2001:888:2000:d::a6]:43952 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:40004 |
Show key headers only | View raw
On 02/26/2013 09:21 AM, Robin Becker wrote:
> In python 2 I was able to improve speed of reportlab using a C extension to optimize some heavily used methods.
>
> so I was able to do this
>
>
> class A:
> .....
> def method(self,...):
> ....
>
>
> try:
> from extension import c_method
> import new
> A.method = new.instancemethod(c_method,None,A)
> except:
> pass
>
> and if the try succeeds our method is bound as a class method ie is unbound and works fine when I call it.
>
> In python 3 this doesn't seem to work at all. In fact the new module is gone. The types.MethodType stuff doesn't seem to
> work.
>
> Is there a way in Python 3.3 to make this happen? This particular method is short, but is called many times so adding
> python wrapping layers is not a good way forward.
Dumb question, but have you tried just assigning it? In Py3 methods are just normal functions...
8<----------------------
class A():
pass
A.method = c_method
8<----------------------
--
~Ethan~
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: python 3 problem: how to convert an extension method into a class Method Ethan Furman <ethan@stoneleaf.us> - 2013-02-26 12:19 -0800
csiph-web