[issue29235] Allow profile/cProfile to be used as context managers

2017-01-15 Thread Thane Brimhall
Thane Brimhall added the comment: I've signed the agreement. I will do the necessary research to figure out how to do unit tests and documentation updates. I should also mention that while maintaining API-compatibility with `profile` was a stated goal, it turns out that the pure-p

[issue29235] Allow profile/cProfile to be used as context managers

2017-01-15 Thread Thane Brimhall
Thane Brimhall added the comment: So this is my first time contributing to Python, but here's a (trivial) patch for this issue. Let me know what else is required to make this happen. I suspect unit tests and documentation updates? -- keywords: +patch Added file: http://bugs.pytho

[issue29238] Add more kwargs to cProfile's print_stats

2017-01-10 Thread Thane Brimhall
New submission from Thane Brimhall: Using the pstats class to print off profiler results is helpful when you want to filter, order, and limit the number of returned lines. I'd rather see the most commonly-used subset of pstats functionality included in the profiler's p

[issue29237] Create enum for pstats sorting options

2017-01-10 Thread Thane Brimhall
New submission from Thane Brimhall: When using the cProfile and pstats modules, I often forget which string keys are available for sorting. It would be nice to add an enum for these so a user could have their linter and IDE check that value pre-runtime. By subclassing both `str` and `Enum

[issue29235] Allow profile/cProfile to be used as context managers

2017-01-10 Thread Thane Brimhall
New submission from Thane Brimhall: The `enable` and `disable` methods on the profilers fit the description of a context manager very well. The following code: pr = cProfile.Profile() pr.enable() # ... do something ... pr.disable() pr.print_stats() Would turn into