On 2/25/06, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
>
>     >> It is currently impossible to separate profile output from the
>     >> program's output.
>
>     Guido> It is if you use the "advanced" use of the profiler -- the
>     Guido> profiling run just saves the profiling data to a file, and the
>     Guido> pstats module invoked separately prints the output.
>
> Sure, but then it's not "simple".  Your original example was "... > file".
> I'd like it to be (nearly) as easy to do it right yet keep it simple.

OK. I believe the default should be stdout though, and the conveniece
method print_stats() in profile.py should be the only place that
references stderr. The smallest code mod would be to redirect stdout
temporarily inside print_stats(); but I won't complain if you're more
ambitious and modify pstats.py.

    def print_stats(self, sort=-1, stream=None):
        import pstats
        if stream is None:
            stream = sys.stderr
        save = sys.stdout
        try:
            if stream is not None:
                sys.stdout = stream
            pstats.Stats(self).strip_dirs().sort_stats(sort). \
                  print_stats()
        finally:
            sys.stdout = save

--
--Guido van Rossum (home page: http://www.python.org/~guido/)
_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to