This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author carljm
Recipients Dennis Sweeney, Mark.Shannon, barry, brandtbucher, carljm, dino.viehland, gregory.p.smith, gvanrossum, itamaro
Date 2022-03-15.15:16:50
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1647357410.4.0.458296407322.issue46896@roundup.psfhosted.org>
In-reply-to
Content
> There should not be much of a slowdown for this code when watching `CONST`:

How and when (and based on what data?) would the adaptive interpreter make the decision that for this code sample the key `CONST`, but not the key `var`, should be watched in the module globals dict? It's easy to contrive an example in which it's beneficial to watch one key but not another, but this is practically irrelevant unless it's also feasible for an optimizer to consistently make the right decision about which key(s) to watch.

The code sample also suggests that the module globals dict for a module is being watched while that module's own code object is being executed. In module body execution, writing to globals (vs reading them) is relatively much more common, compared to any other Python code execution context, and it's much less common for the same global to be read many times. Given this, how frequently would watching module globals dictionaries during module body execution be a net win at all? Certainly cases can be contrived in which it would be, but it seems unlikely that it would be a net win overall. And again, unless the optimizer can reliably (and in advance, since module bodies are executed only once) distinguish the cases where it's a win, it seems the example is not practically relevant.

> Another use of this is to add watch points in debuggers.
> To that end, it would better if the callback were a Python object.

It is easy to create a C callback that delegates to a Python callable if someone wants to implement this use case, so the vectorcall overhead is paid only when needed. The core API doesn't need to be made more complex for this, and there's no reason to impose any overhead at all on low-level interpreter-optimization use cases.
History
Date User Action Args
2022-03-15 15:16:50carljmsetrecipients: + carljm, gvanrossum, barry, gregory.p.smith, dino.viehland, Mark.Shannon, brandtbucher, Dennis Sweeney, itamaro
2022-03-15 15:16:50carljmsetmessageid: <1647357410.4.0.458296407322.issue46896@roundup.psfhosted.org>
2022-03-15 15:16:50carljmlinkissue46896 messages
2022-03-15 15:16:50carljmcreate