On 1/10/2017 11:36 AM, Thane Brimhall wrote:
Does anyone have thoughts on this topic? I assume the silence is because
this suggestion is too trivial to matter.

1 and 3 don't really need discussion here. 2 perhaps. I would open 3 separate enhancement issues. As near as I can tell, profile and cProfile have the same API and to the extent it is true, this should be maintained.

On Tuesday, December 20, 2016 at 5:51:49 PM UTC-7, Thane Brimhall wrote:

    I use cProfile a lot, and would like to suggest three
    backwards-compatible improvements to the API.

    1: When using cProfile on a specific piece of code I often use the
    enable() and disable() methods. It occurred to me that this would be
    an obvious place to use a context manager.

    2: Enhance the `print_stats` method on Profile to accept more
    options currently available only through the pstats.Stats class. For
    example, strip_dirs could be a boolean argument, and limit could
    accept an int. This would reduce the number of cases you'd need to
    use the more complex API.

    3: 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. Since it would subclass
    `str` and `Enum` it would still work with all currently existing code.

--
Terry Jan Reedy

_______________________________________________
Python-ideas mailing list
Python-ideas@python.org
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to