David Cournapeau wrote:
On Mon, Jun 21, 2010 at 12:34 PM, Steven D'Aprano
<steve-remove-t...@cybersource.com.au> wrote:
On Sun, 20 Jun 2010 22:45:14 +0100, Rhodri James wrote:

Mixing Python and assembler is a bizarre thing to want to do in general,
but...

On Sun, 20 Jun 2010 01:52:15 +0100, Steven D'Aprano
<st...@remove-this-cybersource.com.au> wrote:

(3) Modern C compilers can produce better (faster, more efficient)
machine code than the best assembly code written by hand.
No.  Modern C compilers often produce very good machine code, but the
best hand-written assembly code will be better.  I can usually write
*very* marginally better code than GCC achieves at work, though 99% of
the time I don't because it would be a maintenance nightmare.

Not that I don't believe you, but that is an extraordinary claim that
would require more evidence than just "Hey, some guy on the Internet
reckons his assembly code can regularly out-perform optimizing C
compilers" before I will change my opinion *wink*

No, it is not extraordinary claim, I would actually think it is common
knowledge. For performance sensitive, extremely well constraints
algorithm, ASM easily beats general C compilers. Most optimized
numerical libraries rely quite heavily on ASM to get significant speed
up (Atlas, FFTW, MKL). C has actually a few majors aspects which makes
some optimizations very hard to do - things like pointer aliasing, for
example, where the compiler has to be quite pessimistic in general.

Also, the fact that current compilers can generate code which is
significantly faster than they used to a few years ago *on the exact
same C code* show that it is not that hard to beat C compilers. They
manage to do it by themselves :)

A human can write better assembly code than a compiler, but would take a
much longer, and usually for not much gain, so it's usually a waste of
time (premature optimisation, and all that).
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to