pprofile.Profile().print_stats() display in IPython
Question: I tried pprofile to profile Python code line by line.

    
    
    import pprofile
    profiler = pprofile.Profile()
    

I printed the statistics to the Ipython console using

    
    
    profiler.print_stats()
    

This works, however, the plotted table has a lot of rows and the upper part is
cut away by IPython. Since those are the data I'm interested in I need to see
those. Is there any basic IPython setting that enlarges the number of rows to
display? Obviously the profiler.print_stats() command can't be modified to
exclude unneeded data from being displayed.


Answer: There are other methods you could call instead of print_stats(), like

> profiler.dump_stats(filename)

which dumps the same output to filename. Or if you know the name of the file
you are insterested in, you could call the method underlying dump_* methods:

> profiler.annotate(sys.stdout, source_filename)

which dumps an annotated version of just given filename.

See the module/class documentation for more information:

> help(pprofile)

