Matlab equivalent syntax in Python

Robert Kern robert.kern at gmail.com
Sat Nov 27 17:38:46 EST 2010


On 2010-11-26 18:23 , Akand Islam wrote:
> On Nov 26, 3:50 pm, Cameron Simpson<c... at zip.com.au>  wrote:
>> On 26Nov2010 13:15, Akand Islam<sohel... at gmail.com>  wrote:
>> | Thanks for your posting. Like, here is the following Matlab codes
>> | which I am trying to transform into Python. Here you
>> | will find "profile clear, profile on, profile off, profile resume,
>> | profile viewer, and drawnow" syntaxes. So, what will be these
>> | equivalents
>> | in Python?
>>
>> I would start by looking at the "profile" python module:
>>
>>   http://docs.python.org/library/profile.html#module-profile
>>
>> Cheers,
>> --
>> Cameron Simpson<c... at zip.com.au>  DoD#743http://www.cskk.ezoshosting.com/cs/
>>
>> Their are thre mistakes in this sentence.
>>          - Rob Ray DoD#33333<r... at linden.msvu.ca>
>
> Dear Cameron Simpson,
> Thanks for co-operation. I have gone through the link, however, I am
> not much clear. Can you please show me some python syntaxes which
> contain Matlab like "profile on.., drawnow.." and so forth?

Perhaps you could explain what those MATLAB commands do. Not everyone here is 
familiar with MATLAB. For the most part, an API like "profile on; profile off" 
is inappropriate for the "profile" Python module. It profiles the times each 
function call takes, not each line. Turning it on and off doesn't make much 
sense. The API described in the above link is better for what it does.

If you want to visualize the profile, you may want to try RunSnakeRun:

   http://www.vrplumber.com/programming/runsnakerun/

If you want line-by-line profiling, you may want to check out my package, 
line_profiler:

   http://pypi.python.org/pypi/line_profiler/

Again, we don't turn it on and off like you might do in MATLAB. Just follow the 
directions and give up trying to find a correspondence with the MATLAB commands.

-- 
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless enigma
  that is made terrible by our own mad attempt to interpret it as though it had
  an underlying truth."
   -- Umberto Eco




More information about the Python-list mailing list