Re: Python speed vs csharp

Discussion in 'Python' started by Mike, Aug 2, 2003.

  1. Mike

    Mike Guest

    On Wed, 30 Jul 2003 23:09:22 -0700, Mike wrote:

    Wow. Thanks, everyone, for the suggestions.

    As noted in another reply, the full simulation calls the erfc function 150
    milllion times, not 1.5 billion; the elapsed times are correct.

    There doesn't appear to be any way to use previous results in the next
    calculation. I'm calculating the output of a transmission line to a series
    of input pulses. The input pulse sequence is not repetitive, so the output
    doesn't asymptotically approach a final state.

    I had tried the erfc function in the transcendental package (I can't
    remember where I grabbed it from). I didn't try the scipy package, but
    since I already had that installed, I should have tried that first.

    Using psyco, the test case runs in 43 seconds. I was able to reduce that to
    25 seconds using some of the improvements that Bengt Richter provided. I
    was able to reduce the full simulation time down to 647 seconds; I'm sure
    more improvements are possible, since I haven't implemented all of Bengt's
    improvements. Part of the problem with the full simulation is that psyco
    gobbles up all my available memory if I use psyco.full(), so I've been
    experimenting with psyco.bind(). 647 seconds is my best result so far.

    Psyco seems to do a good enough job of optimization that replacing lines
    like

    a1 = 0.254829542
    return ( (a1 + ...

    with

    return ( (0.254829542 + ...

    don't result in any significant change in speed. In addition to the
    math.exp call, the test case called the function like the full simulation
    does, with a math.sqrt(c) in the call, which I replaced with sqrt =
    math.sqrt, then replaced the x**2 with x*x.

    At first glance, I didn't think there was a way to "vectorize" the
    simulation, but after looking at it a little more carefully, it's pretty
    clear that there is.

    At this point, I'm within a factor of 2 of the c# results, and I'm pretty
    much prepared to call that good enough to justify sticking with Python
    instead of learning and converting to c#.

    Thanks again,

    -- Mike --
     
    Mike, Aug 2, 2003
    #1
    1. Advertising

  2. Mike

    Jan Decaluwe Guest

    Mike wrote:
    >



    > improvements. Part of the problem with the full simulation is that psyco
    > gobbles up all my available memory if I use psyco.full(), so I've been
    > experimenting with psyco.bind().


    What about psyco.profile() ? I understood from Armin Rigo that's
    the preferred interface.

    --
    Jan Decaluwe - Resources bvba
    Losbergenlaan 16, B-3010 Leuven, Belgium
    mailto:
    http://jandecaluwe.com
     
    Jan Decaluwe, Aug 2, 2003
    #2
    1. Advertising

  3. Mike

    Mike Guest

    On Sat, 02 Aug 2003 22:59:03 +0200, Jan Decaluwe wrote:

    > Mike wrote:
    >>

    >
    >> improvements. Part of the problem with the full simulation is that psyco
    >> gobbles up all my available memory if I use psyco.full(), so I've been
    >> experimenting with psyco.bind().

    >
    > What about psyco.profile() ? I understood from Armin Rigo that's
    > the preferred interface.


    Since the slow portion of code is well known, I didn't bother to try
    profile(). However...

    Since you mentioned it, I gave it a try, and there's no difference in the
    results between using psyco.bind() on the slow routines and psyco.profile()
    on the entire simulation. However, the difference in effort, and
    corresponding reduction in liklihood of programmer error, is enough to
    justify using the single psyco.profile() line vs multiple psyco.bind()
    lines.

    Thanks,

    -- Mike --
     
    Mike, Aug 3, 2003
    #3
    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. Martin v. =?iso-8859-15?q?L=F6wis?=

    Re: Python speed vs csharp

    Martin v. =?iso-8859-15?q?L=F6wis?=, Jul 31, 2003, in forum: Python
    Replies:
    1
    Views:
    442
    Bengt Richter
    Jul 31, 2003
  2. Richie Hindle

    Re: Python speed vs csharp

    Richie Hindle, Jul 31, 2003, in forum: Python
    Replies:
    3
    Views:
    438
    Richie Hindle
    Aug 1, 2003
  3. David M. Cooke

    Re: Python speed vs csharp

    David M. Cooke, Jul 31, 2003, in forum: Python
    Replies:
    4
    Views:
    467
    Andrew Dalke
    Aug 1, 2003
  4. Bengt Richter

    Re: Python speed vs csharp

    Bengt Richter, Aug 1, 2003, in forum: Python
    Replies:
    1
    Views:
    351
    John Machin
    Aug 2, 2003
  5. Greg Brunet

    Re: Python speed vs csharp

    Greg Brunet, Aug 1, 2003, in forum: Python
    Replies:
    13
    Views:
    607
    Michele Simionato
    Aug 4, 2003
Loading...

Share This Page