Spyder Variable Explorer: forcing automatic refresh after code edits without manual cache clearing
0 reputation · 08 Jun 2023, 18:57 UTC
0 reputation · 08 Jun 2023, 18:57 UTC
I'm working in Spyder (5.x, IPython console backend) and rely heavily on the Variable Explorer to inspect DataFrames and lists while iterating on a script. My understanding is that the Variable Explorer keeps a persistent cache of object representations, so when I mutate a variable in the editor and re-run a cell, the pane keeps showing the old value until I press the Refresh button or use "Clear Cached Data".
I've checked the preferences under Tools > Preferences > Variable Explorer, but I only see options for filtering and display formatting, nothing that ties a refresh to code execution. I also can't find a per-variable or per-session setting that would mark certain objects as "always live" so they're re-evaluated after each run.
My constraints: I want to avoid the performance hit of re-evaluating every large object on each execution, so a blanket auto-refresh of all variables isn't ideal. Ideally only variables I explicitly mark, or only variables below a size threshold, would update automatically.
Is there any supported configuration, plugin hook, or console-side setting in Spyder 5.x that enables selective or threshold-based automatic refresh of the Variable Explorer? If not, is the manual Refresh / "Clear Cached Data" workflow the only intended mechanism, and is this documented as a deliberate design decision?
Direct answer: In Spyder 5.x with an IPython console backend, the Variable Explorer automatically refreshes after each code execution by default. There is no supported configuration, plugin hook, or console-side setting that enables selective or threshold-based automatic refresh (e.g., per-variable "always live" or size-cutoff refresh). The manual Refresh button and "Clear Cached Data" option are the intended user controls for managing cached variable representations.
Likely explanation: The Variable Explorer computes a kernel-side namespace snapshot after each execution, serializing a summary of variable names, types, sizes, and reprs. Very large objects incur cost in repr generation and transfer, so Spyder truncates long representations rather than skipping refresh. This design means refresh applies to the whole namespace, not individual variables with custom flags.
Confirmed facts: The Preferences > Variable Explorer pane only offers filtering, display formatting, and truncation options. No documented plugin hook exists for customizing refresh policy. If values appear stale after a variable was reassigned and executed, the more common cause is that the editor change was never executed in the kernel, or the variable was mutated in-place without re-assignment.
x = 1 in the IPython console and observe whether the Variable Explorer updates without pressing Refresh. This confirms the default refresh-on-execute behavior.Tools > Preferences > Variable Explorer in your installed version and confirm which options exist (filtering, truncation, type exclusion) and that no selective-refresh setting is present.Help > About Spyder for the exact minor version, then consult the Spyder changelog or docs for that version to confirm refresh behavior and any related bug fixes.If values remain stale after a variable was reassigned and executed, that indicates a kernel/console desync rather than intended caching. The practical remedy is to restart the kernel or update Spyder to the latest 5.x minor release.
Note: Exact preference labels and refresh behavior vary across Spyder 5.x minor versions. Verify against your installed version rather than assuming a specific menu layout.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.