Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!eternal-september.org!feeder.eternal-september.org!mx02.eternal-september.org!.POSTED!not-for-mail From: Bartc Newsgroups: comp.programming Subject: Re: compiling python Date: Sun, 25 Jan 2015 01:26:49 +0000 Organization: A noiseless patient Spider Lines: 54 Message-ID: References: <39a759ea-06c0-4e33-93e8-6c5f99fa9303@googlegroups.com> <20150110110749.53@kylheku.com> <20150111112226.707@kylheku.com> <20150124081944.210@kylheku.com> <20150124153738.466@kylheku.com> Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Sun, 25 Jan 2015 01:26:22 +0000 (UTC) Injection-Info: mx02.eternal-september.org; posting-host="cf45b3961a050227b1103bebc3cbc15a"; logging-data="12269"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX187T21cHn5lv5hCJpK/aUWM" User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:31.0) Gecko/20100101 Thunderbird/31.4.0 In-Reply-To: <20150124153738.466@kylheku.com> Cancel-Lock: sha1:drx7FqL21JS7bjUvhXowcZwt8z0= Xref: csiph.com comp.programming:5157 On 24/01/2015 23:54, Kaz Kylheku wrote: > On 2015-01-24, Bartc wrote: >>> (defun test () >>> (do ((i 0 (1+ i))) >>> ((> i 100000000)) >>> (declare >>> (type fixnum i) >>> (optimize (speed 3) (safety 0))))) >> 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. That suggests your machine is at least double the speed of mine, which takes a minimum of 0.7 seconds to perform the loop (and 0.0 to not execute the loop, but that is of no interest). I suppose that for high performance dynamic languages with timings at this end of the scale, then static type information can be a useful extra tweaking method, once all the obvious optimisations have been taken care of. But with un-accelerated Python, Ruby, Perl, etc, those are so inefficient that throwing type hints at them would make little difference. (Seed7, for example, had an even slower interpreter, despite being 100% statically typed. It relied on being compiled to C code to get up to speed.) In my language, type hints could at most double the speed of simple benchmarks, but caused many problems with the interpreter because they really demanded that custom native code sequences were generated, and that data became unboxed, as well as making it harder to have auto-ranging numeric types. It would have turned it into a very different, less dynamic language. It is usually much better, IMO, if you can write dynamic code /without/ having to be tied down by using hints. -- Bartc