Profiling by line with Python 3
How can I do profiling by line in Python 3? 开发者_JS百科The standard profilers have only function-level precision.
While line_profiler only works for Python 2.x, it doesn't seem too hard to make the necessary changes to get it to work with 3.x.
I've done this myself here. It's quick and dirty and pretty much untested, so use it at your peril, but it's possibly a start.
There's a nice Pull Request that implements Python 3 support very well
https://bitbucket.org/robertkern/line_profiler/pull-request/2/python-25-33-compatibility-using-a-single/
As for the line_profiler, a recent working pull request is here waiting for an inclusion. The fork can be installed via:
pip install cython
pip install -e hg+https://bitbucket.org/kmike/line_profiler@7999f21#egg=line_profiler
It works for me at least on Python 3.4.1 with IPython magic functions.
精彩评论