Is this make sence? Dynamic assembler for python

Steven D'Aprano steve at REMOVE-THIS-cybersource.com.au
Sat Jun 19 20:52:15 EDT 2010


On Sat, 19 Jun 2010 13:36:57 -0700, DivX wrote:

> On 19 lip, 21:18, geremy condra <debat... at gmail.com> wrote:
>> On Sat, Jun 19, 2010 at 11:53 AM, DivX <sem.r... at gmail.com> wrote:
>> > I found on the forum some discussion about crypting text and one guy
>> > did make assembly implementation of crypting algorithm. He
>> > dynamically generates mashine code and call that from python. Here
>> > are impressive
>> > resultshttp://www.daniweb.com/code/snippet216632-5.html
>>
>> > Is this better approach then writing extensions in c?
>>
>> No, xor cipher is not suitable for general purpose encryption, and what
>> do you need the speed for? xor is almost certainly not going to be the
>> bottleneck in your application.
>>
>> Geremy Condra
> 
> Just asking if this approach is good for example quicksort algoriths or
> some kind of sorting algorithms, or simulations but the point is of
> mixing python and assembler?


Ask yourself, why aren't programs written in assembly if it's so good?

(1) It's platform dependent. Do you really need a separate program for 
every single hardware platform you want to run Quicksort on?

(2) Writing assembler is hard, really hard. And even harder to debug.

(3) Modern C compilers can produce better (faster, more efficient) 
machine code than the best assembly code written by hand.


Honestly, this question has been resolved twenty years ago -- thirty 
years ago, maybe there was still a good point in writing general purpose 
code in assembly, but now? It's just showing off. Unless you're writing 
hardware specific code (e.g. device drivers) it is pointless, in my 
opinion.

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



More information about the Python-list mailing list