[Python-checkins] CVS: python/dist/src/Lib profile.py,1.26,1.27

Jeremy Hylton jhylton@usw-pr-cvs1.sourceforge.net
Wed, 14 Mar 2001 12:01:21 -0800


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

Modified Files:
	profile.py 
Log Message:
Add doc string for run from profile.doc.  (pydoc motivates me to write
good doc strings.) 

Fix silly argument handling; was using *args but really wanted 1
optional arg.

XXX Should profile.doc be merged into the documentation and removed
from the Lib directory?



Index: profile.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/profile.py,v
retrieving revision 1.26
retrieving revision 1.27
diff -C2 -r1.26 -r1.27
*** profile.py	2001/02/12 02:00:42	1.26
--- profile.py	2001/03/14 20:01:19	1.27
***************
*** 56,62 ****
  #**************************************************************************
  
  
! # simplified user interface
! def run(statement, *args):
      prof = Profile()
      try:
--- 56,70 ----
  #**************************************************************************
  
+ def run(statement, filename=None):
+     """Run statement under profiler optionally saving results in filename
  
!     This function takes a single argument that can be passed to the
!     "exec" statement, and an optional file name.  In all cases this
!     routine attempts to "exec" its first argument and gather profiling
!     statistics from the execution. If no file name is present, then this
!     function automatically prints a simple profiling report, sorted by the
!     standard name string (file/line/function-name) that is presented in
!     each line.
!     """
      prof = Profile()
      try:
***************
*** 64,69 ****
      except SystemExit:
          pass
!     if args:
!         prof.dump_stats(args[0])
      else:
          return prof.print_stats()
--- 72,77 ----
      except SystemExit:
          pass
!     if filename is not None:
!         prof.dump_stats(filename)
      else:
          return prof.print_stats()