Choosing Perl/Python for my particular niche

Fred Ma fma at doe.carleton.ca
Mon Mar 29 19:28:31 EST 2004


Aahz wrote:
> 
> In article <40661C14.8365E058 at doe.carleton.ca>,
> Fred Ma  <fma at doe.carleton.ca> wrote:
> >
> >On the topic of speed, It's surprising to hear that this can be
> >possibly rivaled by Perl/Python, considering that even my matlab code
> >is about 10x slower than C++.  That's with extensive profiling and
> >round-about coding styles to exploit vectorization tricks, and no such
> >effort in the C++ code.
> 
> The reason people say this is because algorithmic experimentation is
> cheap in Python/Perl.  An O(NlogN) algorithm in Python/Perl will lose to
> an O(N^2) algorithm in C/C++ with a few elements, but as the data set
> grows, the O(NlogN) algorithm will pull ahead.


The STL library brings in some efficiently implemented algorithms
to the C++ world instead of having programmings roll their own code.
The problem I saw with matlab was the overhead in between calling
such algorithms.  For example, all the individual built-in's work
fast, but the moment you call your own function, you lose all the
speed that was painfully obtained by carefully crafted code.  In
fact, if you rely on loops containing complex control flow, it
hinders matlab's acceleration technology (which vectorizes loop
operations).  Same with many operators.  In another response, I
mentioned that to ensure that one wouldn't run into similar
difficulties with Perl/Python would require a real-sized
application to be implemented and tested, with all the features
such as overhead between function calls -- a nontrivial task.  So
that's put off as a possibility until after graduation, since
there's more than  enough to try to achieve before then.
Anectdotal accounts are welcome, of course.  Meantime, I'm
looking at Perl/Python for mulching design data to feed various
apps (notably, my algorithms, or to adequately change verilog
files to accommodate limitations in a tool like verilator, as
an example).

Fred
-- 
Fred Ma
Dept. of Electronics, Carleton University
1125 Colonel By Drive, Ottawa, Ontario
Canada, K1S 5B6



More information about the Python-list mailing list