there is a little bug with lambdas and the Profiler: If there is somwhere in
the called function a lambda then the profiler gets an exception....
Michael
#############################################################################
f=lambda x:x*x
print f(3) # f works fine :-)
import profile
p=profile.Profile()
# and now the profiler...
p.runcall(f,3)
Traceback (innermost last):
File "<stdin>", line 1
File "/usr/pub/lib/python/profile.py", line 219
apply(func, args)
File "<stdin>", line -1
File "/usr/pub/lib/python/profile.py", line 43
key = filename + ':' + `lineno` + '(' + funcname + ')'
TypeError: illegal argument type for built-in operation
#############################################################################
here is a patch for profile.py that fixes the problem:
*** old/profile.py Wed May 11 17:01:00 1994
--- new/profile.py Wed Jun 1 12:14:35 1994
***************
*** 40,45 ****
--- 40,46 ----
else:
lineno = codehack.getlineno(frame.f_code)
filename = frame.f_code.co_filename
+ if funcname==None: funcname='lambda'
key = filename + ':' + `lineno` + '(' + funcname + ')'
frame.f_locals['__key'] = key
self.call_level = depth(frame)
***************
*** 135,140 ****
--- 136,142 ----
funcname = frame.f_code.co_name
lineno = codehack.getlineno(frame.f_code)
filename = frame.f_code.co_filename
+ if funcname==None: funcname='lambda'
key = filename + ':' + `lineno` + '(' + funcname + ')'
frame.f_locals['__key'] = key
if self.debug:
***************
*** 146,151 ****
--- 148,154 ----
funcname = frame.f_code.co_name
lineno = codehack.getlineno(frame.f_code)
filename = frame.f_code.co_filename
+ if funcname==None: funcname='lambda'
pkey = filename + ':' + `lineno` + '(' + funcname + ')'
pframe.f_locals['__key'] = pkey
if self.debug:
-- ----------------------------------------------------------------------------- ***** ##### # # ##### # Michael Scharf ******* # ## ## # # # European Molecular Biology Lab. ********* # # # # # # # # Protein Design Group ********* ##### # # # ##### # Meyerhofstr.1 ** ****** # # # # # # 69117 Heidelberg, Germany ******* # # # # # # Tel: +49 6221 387 305 Fax: 517 ***** ##### # # ##### ###### Mail: scharf@EMBL-Heidelberg.de -----------------------------------------------------------------------------