• Re: Ref-strings in logging messages (was: Performance issue with CPytho

    From Skip Montanaro@21:1/5 to All on Fri Oct 7 11:03:08 2022
    Dang autocorrect. Subject first word was supposed to be "f-strings" not "ref-strings." Sorry about that.

    S

    On Fri, Oct 7, 2022, 10:45 AM Skip Montanaro <skip.montanaro@gmail.com>
    wrote:



    On Fri, Oct 7, 2022 at 9:42 AM Andreas Ames <andreas.0815.qwertz@gmail.com> wrote:

    1. The culprit was me. As lazy as I am, I have used f-strings all over the >> place in calls to `logging.logger.debug()` and friends, evaluating all
    arguments regardless of whether the logger was enabled or not.


    I thought there was some discussion about whether and how to efficiently admit f-strings to the logging package. I'm guessing that's not gone
    anywhere (yet).

    Skip


    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Barry@21:1/5 to All on Fri Oct 7 18:04:33 2022
    On 7 Oct 2022, at 16:48, Skip Montanaro <skip.montanaro@gmail.com> wrote:

    On Fri, Oct 7, 2022 at 9:42 AM Andreas Ames <andreas.0815.qwertz@gmail.com>
    wrote:

    1. The culprit was me. As lazy as I am, I have used f-strings all over the >> place in calls to `logging.logger.debug()` and friends, evaluating all
    arguments regardless of whether the logger was enabled or not.


    I thought there was some discussion about whether and how to efficiently admit f-strings to the logging package. I'm guessing that's not gone
    anywhere (yet).

    That cannot be done as the f-string is computed before the log call.

    Maybe you are thinking of the lazy expression idea for this. That idea
    seems to have got no where as its not clear how to implement it without performance issues.

    Barry


    Skip
    --
    https://mail.python.org/mailman/listinfo/python-list


    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From MRAB@21:1/5 to Skip Montanaro on Fri Oct 7 18:10:33 2022
    On 2022-10-07 16:45, Skip Montanaro wrote:
    On Fri, Oct 7, 2022 at 9:42 AM Andreas Ames <andreas.0815.qwertz@gmail.com> wrote:

    1. The culprit was me. As lazy as I am, I have used f-strings all over the >> place in calls to `logging.logger.debug()` and friends, evaluating all
    arguments regardless of whether the logger was enabled or not.


    I thought there was some discussion about whether and how to efficiently admit f-strings to the logging package. I'm guessing that's not gone
    anywhere (yet).

    Letting you pass in a callable to call might help because that you could
    use lambda.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Weatherby,Gerard@21:1/5 to All on Fri Oct 7 17:55:13 2022
    VGhlIG9idmlvdXMgd2F5IHRvIGF2b2lkIGxvZyBnZW5lcmF0aW9uIGlzOg0KDQppZiBsb2dnZXIu aXNFbmFibGVGb3IobG9nZ2luZy5ERUJVRyk6DQogICAgICAgICAgICAgICAgbG9nZ2VyLmRlYnVn KCBleHBlbnNpdmUgcHJvY2Vzc2luZyApDQoNCg0KT2YgY291cnNlLCBoYXZpbmcgbG9nZ2luZyBh bHRlciBwcm9ncmFtIGZsb3cgY291bGQgbGVhZCB0byBoYXJkIHRvIGRlYnVnIGJ1Z3MuDQoNCkZy b206IFB5dGhvbi1saXN0IDxweXRob24tbGlzdC1ib3VuY2VzK2d3ZWF0aGVyYnk9dWNoYy5lZHVA cHl0aG9uLm9yZz4gb24gYmVoYWxmIG9mIEJhcnJ5IDxiYXJyeUBiYXJyeXMtZW1hY3Mub3JnPg0K RGF0ZTogRnJpZGF5LCBPY3RvYmVyIDcsIDIwMjIgYXQgMTozMCBQTQ0KVG86IE1SQUIgPHB5dGhv bkBtcmFiYXJuZXR0LnBsdXMuY29tPg0KQ2M6IHB5dGhvbi1saXN0QHB5dGhvbi5vcmcgPHB5dGhv bi1saXN0QHB5dGhvbi5vcmc+DQpTdWJqZWN0OiBSZTogUmVmLXN0cmluZ3MgaW4gbG9nZ2luZyBt ZXNzYWdlcyAod2FzOiBQZXJmb3JtYW5jZSBpc3N1ZSB3aXRoIENQeXRob24gMy4xMCArIEN5dGhv bikNCioqKiBBdHRlbnRpb246IFRoaXMgaXMgYW4gZXh0ZXJuYWwgZW1haWwuIFVzZSBjYXV0aW9u IHJlc3BvbmRpbmcsIG9wZW5pbmcgYXR0YWNobWVudHMgb3IgY2xpY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21neXFmeUFCYnZSbkEkPg0K

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Barry@21:1/5 to All on Fri Oct 7 18:28:06 2022
    On 7 Oct 2022, at 18:16, MRAB <python@mrabarnett.plus.com> wrote:

    On 2022-10-07 16:45, Skip Montanaro wrote:
    On Fri, Oct 7, 2022 at 9:42 AM Andreas Ames <andreas.0815.qwertz@gmail.com> >>> wrote:
    1. The culprit was me. As lazy as I am, I have used f-strings all over the >>> place in calls to `logging.logger.debug()` and friends, evaluating all
    arguments regardless of whether the logger was enabled or not.

    I thought there was some discussion about whether and how to efficiently
    admit f-strings to the logging package. I'm guessing that's not gone
    anywhere (yet).
    Letting you pass in a callable to call might help because that you could use lambda.

    Yep, that’s the obvious way to avoid expensive log data generation.
    Would need logging module to support that use case.

    Barry

    --
    https://mail.python.org/mailman/listinfo/python-list


    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Julian Smith@21:1/5 to Barry on Fri Oct 7 21:12:42 2022
    On Fri, 7 Oct 2022 18:28:06 +0100
    Barry <barry@barrys-emacs.org> wrote:

    On 7 Oct 2022, at 18:16, MRAB <python@mrabarnett.plus.com> wrote:

    On 2022-10-07 16:45, Skip Montanaro wrote:
    On Fri, Oct 7, 2022 at 9:42 AM Andreas Ames <andreas.0815.qwertz@gmail.com>
    wrote:
    1. The culprit was me. As lazy as I am, I have used f-strings all over the
    place in calls to `logging.logger.debug()` and friends, evaluating all >>> arguments regardless of whether the logger was enabled or not.

    I thought there was some discussion about whether and how to efficiently >> admit f-strings to the logging package. I'm guessing that's not gone
    anywhere (yet).
    Letting you pass in a callable to call might help because that you could use lambda.

    Yep, that’s the obvious way to avoid expensive log data generation.
    Would need logging module to support that use case.

    I have some logging code that uses eval() to evaluate expressions using
    locals and globals in a parent stack frame, together with a parser to
    find `{...}` items in a string.

    I guess this constitutes a (basic) runtime implementation of f-strings.
    As such it can avoid expensive evaluation/parsing when disabled, though
    it's probably slow when enabled compared to native f-strings. It seems
    to work quite well in practise, and also allows one to add some extra formatting features.

    For details see:

    https://git.ghostscript.com/?p=mupdf.git;a=blob;f=scripts/jlib.py;h=e85e9f2c4;hb=HEAD#l41

    - Jules

    --
    http://op59.net

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Barry@21:1/5 to All on Fri Oct 7 22:15:17 2022
    On 7 Oct 2022, at 19:09, Weatherby,Gerard <gweatherby@uchc.edu> wrote:
    The obvious way to avoid log generation is:

    if logger.isEnableFor(logging.DEBUG):
    logger.debug( expensive processing )


    Of course, having logging alter program flow could lead to hard to debug bugs.

    Altered flow is less of an issue the the verbosity of the above.
    We discussed ways to improve this pattern a few years ago.
    That lead to no changes.

    What I have used is a class that defines __bool__ to report if logging is enabled and __call__ to log. Then you can do this:

    log_debug = logger_from(DEBUG)

    log_debug and log_debug(‘expensive %s’ % (complex(),))

    Barry


    From: Python-list <python-list-bounces+gweatherby=uchc.edu@python.org> on behalf of Barry <barry@barrys-emacs.org>
    Date: Friday, October 7, 2022 at 1:30 PM
    To: MRAB <python@mrabarnett.plus.com>
    Cc: python-list@python.org <python-list@python.org>
    Subject: Re: Ref-strings in logging messages (was: Performance issue with CPython 3.10 + Cython)
    *** Attention: This is an external email. Use caution responding, opening attachments or clicking on links. ***

    On 7 Oct 2022, at 18:16, MRAB <python@mrabarnett.plus.com> wrote:

    On 2022-10-07 16:45, Skip Montanaro wrote:
    On Fri, Oct 7, 2022 at 9:42 AM Andreas Ames <andreas.0815.qwertz@gmail.com>
    wrote:
    1. The culprit was me. As lazy as I am, I have used f-strings all over the >>>> place in calls to `logging.logger.debug()` and friends, evaluating all >>>> arguments regardless of whether the logger was enabled or not.
    I thought there was some discussion about whether and how to efficiently >>> admit f-strings to the logging package. I'm guessing that's not gone
    anywhere (yet).
    Letting you pass in a callable to call might help because that you could use lambda.

    Yep, that’s the obvious way to avoid expensive log data generation.
    Would need logging module to support that use case.

    Barry

    --
    https://urldefense.com/v3/__https://mail.python.org/mailman/listinfo/python-list__;!!Cn_UX_p3!mrESxAj9YCHsdtNAfkNiY-Zf6U3WTIqaNrgBmbw1ELlQy51ilob43dD0ONsqvg4a94MEdOdwomgyqfyABbvRnA$<https://urldefense.com/v3/__https:/mail.python.org/mailman/listinfo/
    python-list__;!!Cn_UX_p3!mrESxAj9YCHsdtNAfkNiY-Zf6U3WTIqaNrgBmbw1ELlQy51ilob43dD0ONsqvg4a94MEdOdwomgyqfyABbvRnA$>

    -- https://urldefense.com/v3/__https://mail.python.org/mailman/listinfo/python-list__;!!Cn_UX_p3!mrESxAj9YCHsdtNAfkNiY-Zf6U3WTIqaNrgBmbw1ELlQy51ilob43dD0ONsqvg4a94MEdOdwomgyqfyABbvRnA$<https://urldefense.com/v3/__https:/mail.python.org/mailman/listinfo/
    python-list__;!!Cn_UX_p3!mrESxAj9YCHsdtNAfkNiY-Zf6U3WTIqaNrgBmbw1ELlQy51ilob43dD0ONsqvg4a94MEdOdwomgyqfyABbvRnA$>
    --
    https://mail.python.org/mailman/listinfo/python-list

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Weatherby,Gerard@21:1/5 to All on Sat Oct 8 10:50:51 2022
    TG9nZ2luZyBkb2VzIHN1cHBvcnQgcGFzc2luZyBhIGNhbGxhYmxlLCBpZiBpbmRpcmVjdGx5LiBJ dCBvbmx5IGNhbGxzIF9fc3RyX18gb24gdGhlIG9iamVjdCBwYXNzZWQgaWYgZGVidWdnaW5nIGlz IGVuYWJsZWQuDQoNCmNsYXNzIERlZmVyOg0KDQogICAgZGVmIF9faW5pdF9fKHNlbGYsZm4pOg0K ICAgICAgICBzZWxmLmZuID0gZm4NCg0KICAgIGRlZiBfX3N0cl9fKHNlbGYpOg0KICAgICAgICBy ZXR1cm4gc2VsZi5mbigpDQoNCmRlZiBzb21lX2V4cGVuc2l2ZV9mdW5jdGlvbigpOg0KICAgIHJl dHVybiAiaGVs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8aHR0cHM6Ly91cmxkZWZl bnNlLmNvbS92My9fX2h0dHBzOi9tYWlsLnB5dGhvbi5vcmcvbWFpbG1hbi9saXN0aW5mby9weXRo b24tbGlzdF9fOyEhQ25fVVhfcDMhbXJFU3hBajlZQ0hzZHROQWZrTmlZLVpmNlUzV1RJcWFOcmdC bWJ3MUVMbFF5NTFpbG9iNDNkRDBPTnNxdmc0YTk0TUVkT2R3b21neXFmeUFCYnZSbkEkPg0KPg0K DQotLQ0KaHR0cHM6Ly91cmxkZWZlbnNlLmNvbS92My9fX2h0dHBzOi8vbWFpbC5weXRob24ub3Jn L21haWxtYW4vbGlzdGluZm8vcHl0aG9uLWxpc3RfXzshIUNuX1VYX3AzIW1yRVN4QWo5WUNIc2R0 TkFma05pWS1aZjZVM1dUSXFhTnJnQm1idzFFTGxReTUxaWxvYjQzZEQwT05zcXZnNGE5NE1FZE9k d29tZ3lxZnlBQmJ2Um5BJDxodHRwczovL3VybGRlZmVuc2UuY29tL3YzL19faHR0cHM6L21haWwu cHl0aG9uLm9yZy9tYWlsbWFuL2xpc3RpbmZvL3B5dGhvbi1saXN0X187ISFDbl9VWF9wMyFtckVT eEFqOVlDSHNkdE5BZmtOaVktWmY2VTNXVElxYU5yZ0JtYncxRUxsUXk1MWlsb2I0M2REME9Oc3F2 ZzRhOTRNRWRPZHdvbWd5cWZ5QUJidlJuQSQ+DQo=

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Barry Scott@21:1/5 to All on Mon Oct 24 21:52:12 2022
    On 8 Oct 2022, at 11:50, Weatherby,Gerard <gweatherby@uchc.edu> wrote:

    Logging does support passing a callable, if indirectly. It only calls __str__ on the object passed if debugging is enabled.

    class Defer:

    def __init__(self,fn):
    self.fn = fn

    def __str__(self):
    return self.fn()

    def some_expensive_function():
    return "hello"

    logging.basicConfig()
    logging.debug(Defer(some_expensive_function))

    Oh what a clever hack. Took a few minutes of code reading to see why this works.
    You are exploiting the str(msg) that is in class LogRecords getMessage().

    ```
    def getMessage(self):
    """
    Return the message for this LogRecord.

    Return the message for this LogRecord after merging any user-supplied
    arguments with the message.
    """
    msg = str(self.msg)
    if self.args:
    msg = msg % self.args
    return msg
    ```

    Barry




    From: Python-list <python-list-bounces+gweatherby=uchc.edu@python.org <mailto:python-list-bounces+gweatherby=uchc.edu@python.org>> on behalf of Barry <barry@barrys-emacs.org <mailto:barry@barrys-emacs.org>>
    Date: Friday, October 7, 2022 at 1:30 PM
    To: MRAB <python@mrabarnett.plus.com <mailto:python@mrabarnett.plus.com>>
    Cc: python-list@python.org <mailto:python-list@python.org> <python-list@python.org <mailto:python-list@python.org>>
    Subject: Re: Ref-strings in logging messages (was: Performance issue with CPython 3.10 + Cython)

    *** Attention: This is an external email. Use caution responding, opening attachments or clicking on links. ***

    On 7 Oct 2022, at 18:16, MRAB <python@mrabarnett.plus.com> wrote:

    On 2022-10-07 16:45, Skip Montanaro wrote:
    On Fri, Oct 7, 2022 at 9:42 AM Andreas Ames <andreas.0815.qwertz@gmail.com>
    wrote:
    1. The culprit was me. As lazy as I am, I have used f-strings all over the
    place in calls to `logging.logger.debug()` and friends, evaluating all >>> arguments regardless of whether the logger was enabled or not.

    I thought there was some discussion about whether and how to efficiently >> admit f-strings to the logging package. I'm guessing that's not gone
    anywhere (yet).
    Letting you pass in a callable to call might help because that you could use lambda.

    Yep, that’s the obvious way to avoid expensive log data generation.
    Would need logging module to support that use case.

    Barry

    -- https://urldefense.com/v3/__https://mail.python.org/mailman/listinfo/python-list__;!!Cn_UX_p3!mrESxAj9YCHsdtNAfkNiY-Zf6U3WTIqaNrgBmbw1ELlQy51ilob43dD0ONsqvg4a94MEdOdwomgyqfyABbvRnA$ <https://urldefense.com/v3/__https:/mail.python.org/mailman/listinfo/
    python-list__;!!Cn_UX_p3!mrESxAj9YCHsdtNAfkNiY-Zf6U3WTIqaNrgBmbw1ELlQy51ilob43dD0ONsqvg4a94MEdOdwomgyqfyABbvRnA$>


    -- https://urldefense.com/v3/__https://mail.python.org/mailman/listinfo/python-list__;!!Cn_UX_p3!mrESxAj9YCHsdtNAfkNiY-Zf6U3WTIqaNrgBmbw1ELlQy51ilob43dD0ONsqvg4a94MEdOdwomgyqfyABbvRnA$ <https://urldefense.com/v3/__https:/mail.python.org/mailman/listinfo/
    python-list__;!!Cn_UX_p3!mrESxAj9YCHsdtNAfkNiY-Zf6U3WTIqaNrgBmbw1ELlQy51ilob43dD0ONsqvg4a94MEdOdwomgyqfyABbvRnA$>

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)