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

From Robin Becker <robin@reportlab.com>
Subject Re: python 3 problem: how to convert an extension method into a class Method
Date 2013-02-27 11:11 +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>
Newsgroups comp.lang.python
Message-ID <mailman.2607.1361963479.2939.python-list@python.org> (permalink)

Show all headers | 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