summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>1998-09-21 16:52:44 (GMT)
committerGuido van Rossum <guido@python.org>1998-09-21 16:52:44 (GMT)
commitb0a94c0549f1f757ac8a17fc95e0cf0828d02a70 (patch)
tree02482daca62f9401f50f089c8c1cbb84529879c2
parentf07029e4ba29135368e92a79541ae148d5c7593f (diff)
downloadcpython-b0a94c0549f1f757ac8a17fc95e0cf0828d02a70.zip
cpython-b0a94c0549f1f757ac8a17fc95e0cf0828d02a70.tar.gz
cpython-b0a94c0549f1f757ac8a17fc95e0cf0828d02a70.tar.bz2
Changes so that JPython can also use this version of profile.py.
Suggested by Jim Hugunin.
-rwxr-xr-xLib/profile.py29
1 files changed, 4 insertions, 25 deletions
diff --git a/Lib/profile.py b/Lib/profile.py
index 89fd887..476d598 100755
--- a/Lib/profile.py
+++ b/Lib/profile.py
@@ -244,29 +244,8 @@ class Profile:
def trace_dispatch_call(self, frame, t):
- fn = `frame.f_code`
-
- # The following should be about the best approach, but
- # we would need a function that maps from id() back to
- # the actual code object.
- # fn = id(frame.f_code)
- # Note we would really use our own function, which would
- # return the code address, *and* bump the ref count. We
- # would then fix up the normalize function to do the
- # actualy repr(fn) call.
-
- # The following is an interesting alternative
- # It doesn't do as good a job, and it doesn't run as
- # fast 'cause repr() is written in C, and this is Python.
- #fcode = frame.f_code
- #code = fcode.co_code
- #if ord(code[0]) == 127: # == SET_LINENO
- # # see "opcode.h" in the Python source
- # fn = (fcode.co_filename, ord(code[1]) | \
- # ord(code[2]) << 8, fcode.co_name)
- #else:
- # fn = (fcode.co_filename, 0, fcode.co_name)
-
+ fcode = frame.f_code
+ fn = (fcode.co_filename, fcode.co_firstlineno, fcode.co_name)
self.cur = (t, 0, 0, fn, frame, self.cur)
if self.timings.has_key(fn):
cc, ns, tt, ct, callers = self.timings[fn]
@@ -319,10 +298,10 @@ class Profile:
self.co_filename = filename
self.co_line = line
self.co_name = name
- self.co_code = '\0' # anything but 127
+ self.co_firstlineno = 0
def __repr__(self):
- return (self.co_filename, self.co_line, self.co_name)
+ return repr((self.co_filename, self.co_line, self.co_name))
class fake_frame:
def __init__(self, code, prior):