[Python-checkins] python/dist/src/Lib/hotshot log.py,1.5,1.6

fdrake@users.sourceforge.net fdrake@users.sourceforge.net
Wed, 29 May 2002 12:40:39 -0700


Update of /cvsroot/python/python/dist/src/Lib/hotshot
In directory usw-pr-cvs1:/tmp/cvs-serv24933/Lib/hotshot

Modified Files:
	log.py 
Log Message:
Minor cleanup:
- Add comment explaining the structure of the stack.
- Minor optimization: make stack tuple directly usable as part of return
  value for enter/exit events.


Index: log.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/hotshot/log.py,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** log.py	12 Mar 2002 14:26:37 -0000	1.5
--- log.py	29 May 2002 19:40:36 -0000	1.6
***************
*** 42,45 ****
--- 42,51 ----
          else:
              self.cwd = None
+ 
+         # This mirrors the call stack of the profiled code as the log
+         # is read back in.  It contains tuples of the form:
+         #
+         #   (file name, line number of function def, function name)
+         #
          self._stack = []
          self._append = self._stack.append
***************
*** 100,112 ****
              if what == WHAT_ENTER:
                  filename, funcname = self._decode_location(fileno, lineno)
!                 self._append((filename, funcname, lineno))
!                 return what, (filename, lineno, funcname), tdelta
  
              if what == WHAT_EXIT:
!                 filename, funcname, lineno = self._pop()
!                 return what, (filename, lineno, funcname), tdelta
  
              if what == WHAT_LINENO:
!                 filename, funcname, firstlineno = self._stack[-1]
                  return what, (filename, lineno, funcname), tdelta
  
--- 106,118 ----
              if what == WHAT_ENTER:
                  filename, funcname = self._decode_location(fileno, lineno)
!                 t = (filename, lineno, funcname)
!                 self._append(t)
!                 return what, t, tdelta
  
              if what == WHAT_EXIT:
!                 return what, self._pop(), tdelta
  
              if what == WHAT_LINENO:
!                 filename, firstlineno, funcname = self._stack[-1]
                  return what, (filename, lineno, funcname), tdelta