Sudoku solver

Steven D'Aprano steve+comp.lang.python at pearwood.info
Sat Mar 28 23:06:19 EDT 2015


On Sun, 29 Mar 2015 10:50 am, BartC wrote:


> (X is my own interpreted language, which is where my interest in this
> is. This had been generally faster than Python until PyPy came along. It
> does however use a pure byte-code interpreter, so the result is not too
> bad.
> 
> But using X *and* my own brute-force algorithm, the same puzzle took 2
> seconds to solve - faster than C!


I'm not one of those people who think that C is by definition the fastest
language conceivable. (People who believe this sometimes make an exception
for hand-crafted assembly, which is ironic since these days the best C
optimizing compilers can generate faster, tighter code than human assembly
programmers.) I know that program speed depends on the implementation of
the language, not necessarily the language itself. I know that Fortran can
beat C for numeric work, and that with a tiny fraction of the work put into
optimization that C has seen, modern languages like Scala, Eiffel, Haskell
and D can get to a factor of 2-6 times as slow as C. And I know that PyPy
has managed to beat C in some (quite restrictive, but not completely
unrealistic) benchmarks:

http://morepypy.blogspot.com.au/2011/02/pypy-faster-than-c-on-carefully-crafted.html
http://morepypy.blogspot.com.au/2011/08/pypy-is-faster-than-c-again-string.html


So beating C is not impossible.

But, when you tell me that your very own personal interpreted language,
which I assume nobody else has worked on, is 40% faster than optimized C,
my first reaction is to expect that you've probably made a mistake
somewhere. I would have the same reaction if somebody casually dropped into
a conversation that they happened to beat Usain Bolt's 100m personal best
of 9.58 seconds by almost four seconds. While carrying a 20kg backpack.



-- 
Steven




More information about the Python-list mailing list