From: DivX on
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
results http://www.daniweb.com/code/snippet216632-5.html

Is this better approach then writing extensions in c?
From: geremy condra on
On Sat, Jun 19, 2010 at 11:53 AM, DivX <sem.radi(a)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
> results http://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
From: DivX on
On 19 lip, 21:18, geremy condra <debat...(a)gmail.com> wrote:
> On Sat, Jun 19, 2010 at 11:53 AM, DivX <sem.r...(a)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?
From: Steven D'Aprano on
On Sat, 19 Jun 2010 13:36:57 -0700, DivX wrote:

> On 19 lip, 21:18, geremy condra <debat...(a)gmail.com> wrote:
>> On Sat, Jun 19, 2010 at 11:53 AM, DivX <sem.r...(a)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
From: Terry Reedy on
On 6/19/2010 2:53 PM, DivX 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
> results http://www.daniweb.com/code/snippet216632-5.html
>
> Is this better approach then writing extensions in c?

You have to define 'better'. This approach requires someone to write
template assembler code, which will be machine specific. To be faster
than compiled C on a particular machine, one must be pretty good at
assemblee also.