Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.programming > #5082

Re: compiling python

From BartC <bc@freeuk.com>
Newsgroups comp.programming
Subject Re: compiling python
References <39a759ea-06c0-4e33-93e8-6c5f99fa9303@googlegroups.com> <cPZrw.416147$Kl4.243354@fx01.am4> <20150110110749.53@kylheku.com> <bkhsw.531647$dG.86517@fx32.am4> <20150111112226.707@kylheku.com>
Message-ID <OYAsw.573515$dG.559575@fx32.am4> (permalink)
Organization virginmedia.com
Date 2015-01-11 20:23 +0000

Show all headers | View raw


On 11/01/2015 19:24, Kaz Kylheku wrote:
> On 2015-01-10, BartC <bc@freeuk.com> wrote:
>> On 10/01/2015 19:19, Kaz Kylheku wrote:
>>> On top of that, advanced dynamic languages support optimization. If you
>>> promise to the compiler, via declarations, that a, b, and c have certain
>>> types, then it can generate better code.
>>
>> That wouldn't count as pure Python then (but as a different version,
>> perhaps CPython). When I tried adding type info to my own language
>> efforts, the modest gains weren't worth the extra complexity or losing
>> the elegance of the language's variant types.
>
> I see, and whatever you've been able to achieve is representative of
> what is possible. Nay, the upper bound.

As I said, you end up with a different language. It's an inelegant way 
of squeezing extra speed out of it. For example:

function add(a,b) return a+b

This function will work for integers, floats, strings, lists, sets, even 
other user types when the correct overload exists. But it's a bit slow. 
So I create this version:

function add(int a,b)int return a+b

Now it's a bit faster ... for ints. For anything else it now raises an 
error. The natural generics you get with this kind of language goes out 
the window.

My own dynamic, interpreted languages have until recently outperformed 
languages such as Python, Lua, Perl, and Ruby by a magnitude or so. Now 
there are new ways to accelerate those languages, but usually they don't 
involve something as crude as having to add static type info.

I don't need to use such complex methods (and some are very complex) 
because my own effort still performs pretty well. And when I need 
something fast, I just use another of my languages which /is/ statically 
typed.

That can give me an easy 1000% speedup rather than the 50% I might get 
by bolting on static declarations to the other language (at least, 
without changing dramatically changing the structure of the bytecode 
interpreter, but I want to keep that simple and focused).

So my solution is to use two languages, which conveniently both happen 
to have the same syntax; one with dynamic typing, the other static typing.

 > I see, and whatever you've been able to achieve is representative of
 > what is possible. Nay, the upper bound.

That static language has been developed as a replacement for C. Last 
time I checked, that had a typical performance something like 50% slower 
than using gcc with the highest optimisation. That is actually pretty 
good, considering how much effort has gone into gcc.

(30 years ago however my own compilers were generally faster than C 
ones. It's a taken a few years for them to catch up!)

-- 
Bartc

Back to comp.programming | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

compiling python fir <profesor.fir@gmail.com> - 2015-01-09 15:36 -0800
  Re: compiling python BartC <bc@freeuk.com> - 2015-01-09 23:50 +0000
    Re: compiling python fir <profesor.fir@gmail.com> - 2015-01-09 15:59 -0800
      Re: compiling python BartC <bc@freeuk.com> - 2015-01-10 11:45 +0000
        Re: compiling python fir <profesor.fir@gmail.com> - 2015-01-10 07:09 -0800
    Re: compiling python Kaz Kylheku <kaz@kylheku.com> - 2015-01-10 19:19 +0000
      Re: compiling python BartC <bc@freeuk.com> - 2015-01-10 22:02 +0000
        Re: compiling python fir <profesor.fir@gmail.com> - 2015-01-11 10:52 -0800
        Re: compiling python Kaz Kylheku <kaz@kylheku.com> - 2015-01-11 19:24 +0000
          Re: compiling python BartC <bc@freeuk.com> - 2015-01-11 20:23 +0000
          Re: compiling python BartC <bc@freeuk.com> - 2015-01-24 15:01 +0000
            Re: compiling python Kaz Kylheku <kaz@kylheku.com> - 2015-01-24 16:58 +0000
              Re: compiling python Bartc <bc@freeuk.com> - 2015-01-24 19:18 +0000
                Re: compiling python Kaz Kylheku <kaz@kylheku.com> - 2015-01-24 23:54 +0000
                Re: compiling python Bartc <bc@freeuk.com> - 2015-01-25 01:26 +0000
  Re: compiling python Robert Wessel <robertwessel2@yahoo.com> - 2015-01-09 18:13 -0600
    Re: compiling python fir <profesor.fir@gmail.com> - 2015-01-09 16:27 -0800
  Re: compiling python Mok-Kong Shen <mok-kong.shen@t-online.de> - 2015-01-12 18:28 +0100

csiph-web