How to make Python run as fast (or faster) than Julia

Chris Angelico rosuav at gmail.com
Fri Feb 23 14:47:00 EST 2018


On Sat, Feb 24, 2018 at 6:25 AM, bartc <bc at freeuk.com> wrote:
> On 23/02/2018 18:05, Steven D'Aprano wrote:
>>
>> On Fri, 23 Feb 2018 13:51:33 +0000, Ben Bacarisse wrote:
>
>
>> Stop writing crap code and then complaining that the language is "too
>> slow". Write better code, and then we'll take your complaints seriously.
>
>
> I write compilers for static languages, which are generally considered toys,
> partly because the code generated is not great.

Doesn't matter what language you're writing in, if your algorithm is
flawed. Bubble sort is bubble sort no matter what you're using. This
function will calculate triangle numbers just as inefficiently in
Python as it would in C:

def triangle(n):
    if n <= 1: return n
    return triangle(n-1) + triangle(n-1) - triangle(n-2) + 1


> But in a real application, the difference between my compiler, and gcc-O3 or
> MSVC/O2 might only be 10-50%. 1.1 to 1.5 times as fast (or as slow), and
> that's an application that does few external library calls.
>
> The difference between Python and another dynamic language might be a
> magnitude, yet you say it doesn't matter.
>
> Thanks, that makes me feel much better about my own work! If a magnitude
> difference in performance can be so casually dismissed.

Yep! Your work is awesome, because your code is only a little bit
slower than the same algorithm with the same bugs in a better-known
language that's supported on more platforms and has a large team of
people supporting it.

Remind me what's actually advantageous about your language?

ChrisA



More information about the Python-list mailing list