I\'m trying to profile an instance method, so I\'ve done something like:
import cProfile
class Test():
def __init__(self):
pass
def method
I was struggling with the same problem and used a wrapper function to get over direct return values. Instead of
cP.runctx("a=foo()", globals(), locales())
I create a wrapper function
def wrapper(b):
b.append(foo())
and profile the call to the wrapper function
b = []
cP.runctx("wrapper(b)", globals(), locals())
a = b[0]
extracting the result of foo's computation from the out param (b) afterwards.