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

Discussion in 'Python' started by Robin Becker, Feb 27, 2013.

  1. Robin Becker

    Robin Becker Guest

    On 27/02/2013 10:49, Chris Angelico wrote:
    > On Wed, Feb 27, 2013 at 9:36 PM, Robin Becker <> 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
    Robin Becker, Feb 27, 2013
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Robin Becker
    Replies:
    1
    Views:
    122
    Steven D'Aprano
    Feb 27, 2013
  2. Dave Angel
    Replies:
    0
    Views:
    113
    Dave Angel
    Feb 26, 2013
  3. Peter Otten
    Replies:
    0
    Views:
    110
    Peter Otten
    Feb 26, 2013
  4. Mark Lawrence
    Replies:
    0
    Views:
    121
    Mark Lawrence
    Feb 26, 2013
  5. Peter Otten
    Replies:
    0
    Views:
    122
    Peter Otten
    Feb 26, 2013
Loading...

Share This Page