Prev: MAKE UPTO $5000 PER MONTH! $2000 IN FIRST 30 DAYS!
Next: introducing Lettuce, BDD tool for python with Django integration
From: Rhodri James on 20 Jun 2010 17:45 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 <steve(a)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. I wrote more at a previous job, but then the processor had instructions that could not be expressed usefully in C, and having an FFT routine that ran like greased lightning was important. I would agree, though, that the only reason I can think of for wanting to mix Python and assembler is if you are grobbling about with hardware, and if you are doing that, Python wasn't the best place to start from. -- Rhodri James *-* Wildebeeste Herder to the Masses
From: Dave Angel on 20 Jun 2010 18:21 DivX wrote: > On 20 lip, 12:46, Steven D'Aprano <st...(a)REMOVE-THIS- > cybersource.com.au> wrote: > >> On Sun, 20 Jun 2010 03:19:48 -0700, DivX wrote: >> >>> On 20 lip, 02:52, Steven D'Aprano <st...(a)REMOVE-THIS- >>> cybersource.com.au> wrote: >>> >> [...] >> >>>> I think that mixing assembly and python is a gimmick of very little >>>> practical significance. If you really need the extra performance, check >>>> out PyPy, Cython, Pyrex and Psyco. >>>> >>>> -- >>>> Steven >>>> >>> I can agree with you about most of the arguments, but why he continues >>> to developing it. What he sees and we do not see? >>> >> Why ask us? You should ask him. >> >> -- >> Steven >> > > Be sure I will ask him, but before, I wanted to know your opinions > about it. Hear arguments on both sides... > > Something's intrinsically wrong with the argument made in this thread against generating assembly code. That's exactly what happens every time you write code in C. The real question is whether the code generator your friend is writing is better than the ones written by dozens of C gurus over the years, and better tuned to the requirements of his particular processor. Naturally, better can be measured in several ways. For example, I have a processor for which no C compiler is available. So if I were to want optimized assembler, I might need to write one myself, or use the language for which such a code generator has been written. DaveA
From: Steven D'Aprano on 20 Jun 2010 23:28 On Sun, 20 Jun 2010 18:21:43 -0400, Dave Angel wrote: > Something's intrinsically wrong with the argument made in this thread > against generating assembly code. That's exactly what happens every > time you write code in C. I don't know whether C compilers generate assembly mnemonics or direct machine code, but the distinction for this argument is irrelevant. The argument in this thread is that it's not worth the *human coder* writing assembly, not that no assembly code is involved in the process anywhere. -- Steven
From: Paul Rubin on 21 Jun 2010 00:37 Steven D'Aprano <steve-REMOVE-THIS(a)cybersource.com.au> writes: > 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* It is really true, and it's the opposite claim that would be extraordinary. That's why compilers like gcc include pragmas for assembler intrinsics for when you want include some inline assembly code in your C program. gzip uses it for example, as does Gnu MP and OpenSSL. That's why gmpy is several times faster at multi-precision arithmetic than Python's built-in longs, that are implemented in C. Another reason for wanting dynamic assembly code is so you can embed staged programming in your python code. Think of how slow python regexps are. Now imagine a regexp package that compiles your regexp directly to assembly code instead of to some silly interpreted state machine. Parser generators like pyparsing could similarly generate asm code directly.
From: Dave Angel on 21 Jun 2010 03:00 Steven D'Aprano wrote: > On Sun, 20 Jun 2010 18:21:43 -0400, Dave Angel wrote: > > >> Something's intrinsically wrong with the argument made in this thread >> against generating assembly code. That's exactly what happens every >> time you write code in C. >> > > I don't know whether C compilers generate assembly mnemonics or direct > machine code, but the distinction for this argument is irrelevant. > > The argument in this thread is that it's not worth the *human coder* > writing assembly, not that no assembly code is involved in the process > anywhere. > > > But the OP said of his friend: "He dynamically generates mashine code and call that from python." I took that to mean he dynamically generated machine code, not that he hired some human to do it. DaveA
First
|
Prev
|
Next
|
Last
Pages: 1 2 3 4 5 Prev: MAKE UPTO $5000 PER MONTH! $2000 IN FIRST 30 DAYS! Next: introducing Lettuce, BDD tool for python with Django integration |