diff options
author | Fred Drake <fdrake@acm.org> | 2003-05-14 14:28:09 (GMT) |
---|---|---|
committer | Fred Drake <fdrake@acm.org> | 2003-05-14 14:28:09 (GMT) |
commit | 9c43910a278ca2a44a6e2d31d53270b05cd7dc5e (patch) | |
tree | 1b8c8a837a75579b46583062e030ef885bd51390 /Lib | |
parent | c868d16e11acf4a8589a6bf1e6e720c063b3877f (diff) | |
download | cpython-9c43910a278ca2a44a6e2d31d53270b05cd7dc5e.zip cpython-9c43910a278ca2a44a6e2d31d53270b05cd7dc5e.tar.gz cpython-9c43910a278ca2a44a6e2d31d53270b05cd7dc5e.tar.bz2 |
- add a dump_stats() method similar to that of the profile.Profile class
- don't use "file" as the name of local variables
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/pstats.py | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/Lib/pstats.py b/Lib/pstats.py index 62854a8..9e202e9 100644 --- a/Lib/pstats.py +++ b/Lib/pstats.py @@ -158,6 +158,14 @@ class Stats: self.stats[func] = add_func_stats(old_func_stat, stat) return self + def dump_stats(self, filename): + """Write the profile data to a file we know how to load back.""" + f = file(filename, 'wb') + try: + marshal.dump(self.stats, f) + finally: + f.close() + # list the tuple indices and directions for sorting, # along with some printable description sort_arg_dict_default = { @@ -440,8 +448,8 @@ class TupleComp: # func_name is a triple (file:string, line:int, name:string) def func_strip_path(func_name): - file, line, name = func_name - return os.path.basename(file), line, name + filename, line, name = func_name + return os.path.basename(filename), line, name def func_get_function_name(func): return func[2] |