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


Groups > comp.lang.python > #40051

Re: python 3 problem: how to convert an extension method into a class Method

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 <python-python-list@m.gmane.org>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.003
X-Spam-Evidence '*H*': 0.99; '*S*': 0.00; 'raises': 0.07; 'python': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'subject:into': 0.09; 'subject:method': 0.09; 'utf8': 0.09; 'cc:addr:python-list': 0.10; 'subject:python': 0.11; 'extension': 0.13; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'subject: \n ': 0.16; 'subject:class': 0.16; 'wed,': 0.16; 'wrote:': 0.17; 'bytes': 0.17; 'instance': 0.17; 'refers': 0.17; 'unicode': 0.17; 'tests': 0.18; 'code,': 0.18; 'feb': 0.19; 'back.': 0.22; 'subject:problem': 0.22; 'cc:2**0': 0.23; 'class.': 0.23; "python's": 0.23; 'cc:no real name:2**0': 0.24; 'feature': 0.24; 'cc:addr:python.org': 0.25; 'header:In-Reply-To:1': 0.25; 'header:User-Agent:1': 0.26; 'header:X-Complaints-To:1': 0.28; 'chris': 0.28; 'cpu': 0.29; 'question:': 0.29; 'function': 0.30; 'code': 0.31; 'purposes,': 0.33; 'to:addr:python-list': 0.33; 'times.': 0.33; 'pm,': 0.35; "won't": 0.35; 'something': 0.35; 'received:org': 0.36; 'really': 0.36; 'method': 0.36; 'does': 0.37; 'subject:: ': 0.38; 'fact': 0.38; 'sure': 0.38; 'performance': 0.39; 'to:addr:python.org': 0.39; 'takes': 0.39; 'called': 0.39; 'little': 0.39; 'header:Received:5': 0.40; 'think': 0.40; 'your': 0.60; 'easy': 0.60; 'between': 0.63; 'here': 0.65; 'god': 0.66; 'obvious': 0.71; 'saving': 0.72; 'goal': 0.74; 'received:109': 0.74; '2013': 0.84; 'benchmark': 0.84; 'sfxlen:4': 0.84; 'pfxlen:big': 0.91
X-Injected-Via-Gmane http://gmane.org/
To python-list@python.org
From Robin Becker <robin@reportlab.com>
Subject Re: python 3 problem: how to convert an extension method into a class Method
Date Wed, 27 Feb 2013 11:11:08 +0000
References <512CEF0C.3020906@chamonix.reportlab.co.uk> <kgivf6$ojl$1@ger.gmane.org> <512DE1AB.7000100@chamonix.reportlab.co.uk> <CAPTjJmrCkX-mdkHFQ97DKiZHTcyU87oPt+x9tE0NF65g5200zQ@mail.gmail.com>
Mime-Version 1.0
Content-Type text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding 7bit
Cc python-list@python.org
X-Gmane-NNTP-Posting-Host 109.174.168.73
User-Agent Mozilla/5.0 (Windows NT 5.1; rv:17.0) Gecko/20130215 Thunderbird/17.0.3
In-Reply-To <CAPTjJmrCkX-mdkHFQ97DKiZHTcyU87oPt+x9tE0NF65g5200zQ@mail.gmail.com>
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.2607.1361963479.2939.python-list@python.org> (permalink)
Lines 29
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1361963479 news.xs4all.nl 6878 [2001:888:2000:d::a6]:50405
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:40051

Show key headers only | View raw


On 27/02/2013 10:49, Chris Angelico wrote:
> On Wed, Feb 27, 2013 at 9:36 PM, Robin Becker <robin@reportlab.com> wrote:
>> However, in my case the method takes
>>
>>
>>
>>                        py  C
>> utf8 bytes            50  20 usec
>> unicode               39  15
>>
>> here py refers to a native python method and C  to the extension method
>> after adding to the class. Both are called via an instance of the class.
>
> Which raises the obvious question: Does it even matter? Will the
> saving of a few microseconds really make a difference? Python's best
> feature is its clarity of code, not its blazing performance; its
> performance goal is "fast enough", and for many MANY purposes, you
> won't be able to tell the difference between that and "awesome". Don't
> sacrifice your code's clarity to the little tin god of efficiency
> until you're sure you actually get something back.
>
> ChrisA
>
in fact this is the stringWidth function and it's used thousands of times. I 
think when we did benchmark tests it came out as 1 or 2 as a cpu hog. Since it's 
comparatively easy to code it's an obvious choice to move to C.
-- 
Robin Becker

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


Thread

Re: python 3 problem: how to convert an extension method into a class Method Robin Becker <robin@reportlab.com> - 2013-02-27 11:11 +0000

csiph-web