Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.programming > #5156
| From | Kaz Kylheku <kaz@kylheku.com> |
|---|---|
| Newsgroups | comp.programming |
| Subject | Re: compiling python |
| Date | 2015-01-24 23:54 +0000 |
| Organization | Aioe.org NNTP Server |
| Message-ID | <20150124153738.466@kylheku.com> (permalink) |
| References | (3 earlier) <bkhsw.531647$dG.86517@fx32.am4> <20150111112226.707@kylheku.com> <TsOww.430908$BB2.193851@fx35.am4> <20150124081944.210@kylheku.com> <ma0r5t$nkt$1@dont-email.me> |
On 2015-01-24, Bartc <bc@freeuk.com> wrote: >>> You can see there is quite a difference (some 30 times slower) between >>> my little language and Python. >> >> Clozure Common Lisp: >> >> (defun test () >> (do ((i 0 (1+ i))) >> ((> i 100000000)) >> (declare >> (type fixnum i) >> (optimize (speed 3) (safety 0))))) >> >> CPU: Intel Core-i5-2310, 2.9 GHz. >> >> ? (time (test)) >> (TEST) >> took 210 milliseconds (0.210 seconds) to run. > > OK, let's say 2.1 seconds for a billion. That compares very well with > the above timings (ignoring the fact that your machine might be faster > or slower than mine). One billion doesn't fit into a fixnum on the 32 bit version of Clozure Common Lisp. On the 64 bit version I get more meaningful looking timings. ? (time (test)) (TEST) took 1,329,000 microseconds (1.329000 seconds) to run. Now with the version with declarations, there is a difference: ? (time (test)) (TEST) took 345,000 microseconds (0.345000 seconds) to run. Other data points, using LOOP instead of DO: ? (time (loop for i below 1000000000)) (LOOP FOR I BELOW 1000000000) took 1,330,000 microseconds (1.330000 seconds) to run. ? (time (loop for i fixnum below 1000000000)) (LOOP FOR I FIXNUM BELOW 1000000000) took 675,000 microseconds (0.675000 seconds) to run. > CLISP took 65 seconds for the above, so presumably 10-11 minutes for a > billion. This is on the same machine where my /bytecode interpreter/ > executes in 3.7 seconds. In CLISP, you have to compile code explicitly. Try [1]> (compile 'test) then repeat. However, note that the type annotations are wrong: [2]> most-positive-fixnum 16777215 Oops! Looks like fixnums are only 25 bits including sign, on a 32 bit build. On a 64 bit Debian box where I have a 64 bit CLISP: [1]> most-positive-fixnum 281474976710655 Note that in Lisp, if you use declarations, and request (safety 0), you get undefined behavior if the program lies. Declarations must be regarded as *promises* to the compiler that you know what you're doing, rather than request for type checking. >> ? (disassemble 'test) ><snip> > > So you're saying it doesn't matter too much whether static type > information is present or not? I think the number of iterations may just have been too short for accurate timing. > But it seems that you have a very effective language which is capable of > generating fast native code; why doesn't Python do the same? (Maybe it Clozure Common Lisp was previously known as OpenMCL. http://en.wikipedia.org/wiki/Macintosh_Common_Lisp#History_of_MCL There are other Common Lisps with good compilers. > could just be translated to your Lisp!) There is such a project: http://common-lisp.net/project/clpython/
Back to comp.programming | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll 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