On Wed, Nov 08, 2006 at 01:32:44AM -0700, Fernando Perez wrote:
> Hi all,
>
> in the past, Arnd Baecker has made a number of very useful posts on
> this matter, and provided some nice utilities to do it. I now needed
> to profile some fairly complex codes prior to a big optimization push,
> so I went over his material and wrote a little tool to make the whole
> process as painless as possible. Here it is, hoping others may find
> it useful:
>
> http://amath.colorado.edu/faculty/fperez/python/profiling/
This looks very interesting. It works for me on simple scripts, but
whenever I include the lines
from numpy.testing import set_local_path
set_local_path('../../..')
in the input, pycachegrind aborts with
File "/home/stefan//lib/python2.4/site-packages/numpy/testing/numpytest.py",
line 68, in set_local_path
if f.f_locals['__name__']=='__main__':
KeyError: '__name__'
I guess this is because the script is run in a separate namespace.
I've managed to work around the problem by changing the definition of
'run' to:
def run(code):
loc = locals()
loc['__name__'] = '__main__'
loc['__file__'] = sys.argv[0]
exec code in locals()
Cheers
Stéfan
-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Numpy-discussion mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/numpy-discussion