Speed-up for loops

MRAB python at mrabarnett.plus.com
Wed Sep 8 04:07:09 CEST 2010


On 08/09/2010 02:45, BartC wrote:
>
>
> "David Cournapeau" <cournape at gmail.com> wrote in message
> news:mailman.546.1283897932.29448.python-list at python.org...
>> On Sun, Sep 5, 2010 at 8:28 PM, BartC <bartc at freeuk.com> wrote:
>>
>>>
>>> One order of magnitude (say 10-20x slower) wouldn't be so bad. That's
>>> what
>>> you might expect for a dynamically typed, interpreted language.
>>
>> 10/20x slower than C is only reached by extremely well optimized
>> dynamic languages. It would be a tremendous achievement. If that's
>
> Well, that is what I do (mess around with languages and stuff).
>
> Getting back to the OP's code again (trivial and pointless as it might
> seem), I got these results:
>
> C (gcc 3.4.5 -O3) 0.8 secs
> C (DMC-o) 2.3 secs
> C (lccwin32 -O) 2.9 secs
> My last interpreter 12.6 secs dynamically typed language
> (or 4.5 secs when told the type of 'a'; but that's
> cheating a little..)
> Python 3 177.0 secs
>
> That's why I was questioning the latter's performance in for-loops. But now
> that I know a bit more about Python (having dynamic everything) the figure
> is not so surprising. However, it's still slow!
>
>> what you are after, look at LUA with its JIT, or scheme + stalin.
>
> I've seen LuaJIT in action. It's timing for this test is 1.5 secs:
> forget being only 10x slower than C, it's faster than some C versions!
> (I'm sure it must be cheating somewhere...)
>
If you'd like to direct your skills to making CPython faster, without
diminishing its flexibility, I'm sure it'll be welcomed. The source is
all public, you know! :-)



More information about the Python-list mailing list