Skip to content

ENH: Use line profiler as context manager #357

@skjerns

Description

@skjerns

I'm using an IDE with REPL and execute many lines of code individually. Sometimes I would quickly like to assess which lines in some multi-line codes are slowest

How difficult would it be to integrate line_profiler as a context manager, without manual overhead of wrapping the statement in a function? This would be similar to the ipython cell magic, but without the cell

Something along those lines:

with lineprofiler:
    func()
    func2()
    func3()


#>L1 func()   - 0.200s - 20%
#>L2 func2() - 0.450s - 45%
#>L3 func3() - 0.350s - 35%

related #127, it seems like this was possible (?) in Python 2. Is there a reason it is not working anymore in Python 3?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions