Skip to content

%prun: Restore stats.stream after running print_stream.#2092

Merged
minrk merged 1 commit into
ipython:masterfrom
bfroehle:prun_print_stats
Jul 21, 2012
Merged

%prun: Restore stats.stream after running print_stream.#2092
minrk merged 1 commit into
ipython:masterfrom
bfroehle:prun_print_stats

Conversation

@bfroehle
Copy link
Copy Markdown
Contributor

@bfroehle bfroehle commented Jul 3, 2012

When profiling, the output from print_stream is captured so that the output can be paged. To do so, the stream attribute is set to a StringIO object but was not restored after the output was captured. As a result, the stats object returned by %prun -r did not display any output when calling its print_stream method.

In addition, the pstats.Stats class has the stream attribute for all currently supported Python versions (2.6, 2.7, and 3.2, at least), so the extra branch of code can be removed.

Closes #2091.

When profiling, the output from `print_stream` is captured so that the
output can be paged. To do so, the `stream` attribute is set to a
`StringIO` object but was not restored after the output was captured.
As a result, the stats object returned by `%prun -r` did not display
any output when calling its `print_stream` method.

In addition, the `pstats.Stats` class has the `stream` attribute for
all currently supported Python versions, so the extra branch of code
can be removed.
@minrk
Copy link
Copy Markdown
Member

minrk commented Jul 21, 2012

Looks simple and clean. Thanks!

@minrk
Copy link
Copy Markdown
Member

minrk commented Jul 21, 2012

Test results for commit cb56d19 merged into master
Platform: darwin

  • python2.6: OK (libraries not available: cython matplotlib oct2py pygments pymongo qt rpy2 tornado wx wx.aui)
  • python2.7: OK (libraries not available: oct2py wx wx.aui)
  • python3.2: OK (libraries not available: cython matplotlib oct2py pymongo qt rpy2 wx wx.aui)

Not available for testing:

minrk added a commit that referenced this pull request Jul 21, 2012
%prun: Restore `stats.stream` after running `print_stream`

When profiling, the output from `print_stream` is captured so that the output can be paged. To do so, the `stream` attribute is set to a `StringIO` object but was not restored after the output was captured. As a result, the stats object returned by `%prun -r` did not display any output when calling its `print_stream` method.

In addition, the `pstats.Stats` class has the `stream` attribute for all currently supported Python versions (2.6, 2.7, and 3.2, at least), so the extra branch of code can be removed.

Closes #2091
@minrk minrk merged commit 965fc65 into ipython:master Jul 21, 2012
mattvonrocketstein pushed a commit to mattvonrocketstein/ipython that referenced this pull request Nov 3, 2014
%prun: Restore `stats.stream` after running `print_stream`

When profiling, the output from `print_stream` is captured so that the output can be paged. To do so, the `stream` attribute is set to a `StringIO` object but was not restored after the output was captured. As a result, the stats object returned by `%prun -r` did not display any output when calling its `print_stream` method.

In addition, the `pstats.Stats` class has the `stream` attribute for all currently supported Python versions (2.6, 2.7, and 3.2, at least), so the extra branch of code can be removed.

Closes ipython#2091
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Unable to use print_stats after %prun -r in notebook

2 participants