Profiling problem
greg andruk
meowing at banet.net
Fri May 7 15:07:31 EDT 1999
Randall Hopper <aa8vb at vislab.epa.gov> writes:
> langref, I'm still not sure why this doesn't work.
>>>> class C:
> ... def slow_dog( self ):
> ... import time
> ... time.sleep(5)
> ... def doit( self ):
> ... import profile
> ... profile.run( 'self.slow_dog()' )
> ...
>>>> c = C()
>>>> c.doit()
> NameError: self
The problem is that you have to pass the function name as a string,
and self.slow_dog is only going to be known inside this instance.
(profile will have its own, different idea of what self is, object
orientation being object oriented and all).
So, cheat!
class C:
def slow_dog( self ):
import time
time.sleep(5)
def doit( self ):
global see_thru_skin
import profile
see_thru_skin = self.slow_dog
profile.run( 'see_thru_skin()' )
--
Misc. Meowing: <URL:http://members.xoom.com/meowing/> **meow**
More information about the Python-list
mailing list