pudb icon indicating copy to clipboard operation
pudb copied to clipboard

Add global and "by reference" watches

Open mvanderkamp opened this issue 2 years ago • 4 comments

Addresses #511

Allows modifying watch expressions in two ways:

  1. Whether to show the watch expression in all frames as opposed to only the current frame
  2. Whether to continually re-evaluate the watch expression or evaluate it when it is created, cache the result, and watch changes to this value over time. If the value appears in the current local or global namespaces, it's current name is shown in parentheses.

mvanderkamp avatar Jun 29 '22 18:06 mvanderkamp

Actually what do you think of making all watches "global"? That's usually how I want watches to behave.

mvanderkamp avatar Jul 03 '22 16:07 mvanderkamp

Hmm just as well I'm not entirely happy with the state of this- we don't have access to the right InspectInfo for global watches since it's still being cached at the frame level, so the global watches are presented differently (display type, show detail, etc) in each frame.

mvanderkamp avatar Jul 16 '22 00:07 mvanderkamp

Also, any thoughts on the UI for this stuff? I went with "expression"/"reference" since that made sense to me at the time but "by name"/"by value" might make more sense. And how cumbersome is it to have potentially 4 different kinds of watches?

mvanderkamp avatar Jul 16 '22 00:07 mvanderkamp

Haven't read up all the watch-related stuff, but here is a late night thought: What about showing (some) watch values only when their evaluation does not fail? Put differently, hiding all watches that yield a WatchEvalError.

This is what comes to mind after seeing the behavior of https://github.com/inducer/pudb/pull/150, which saves watch expressions and loads them in every entered frame, which of course fails in many cases.

raphCode avatar Apr 25 '23 22:04 raphCode