Skip to content

Centralize cache resets for source sample generation - #115

Open
15r10nk wants to merge 2 commits into
alexmojaki:masterfrom
15r10nk:clear-source-lookup-caches
Open

15r10nk wants to merge 2 commits into
alexmojaki:masterfrom
15r10nk:clear-source-lookup-caches

Conversation

@15r10nk

@15r10nk 15r10nk commented Nov 26, 2026

Copy link
Copy Markdown
Collaborator

The source sample generator currently drops the source and execution caches between files, but shared statement and instruction caches can still retain metadata from previous files. Add an internal Source._clear_caches() helper and use it in the generator to clear those caches together with linecache.

The helper also supports clearing only the execution cache while retaining parsed sources and metadata. Tests cover both reset modes, rebuilding lookups, and the distinction between class-local and shared caches. Existing Source objects are not modified.

Validation:

  • Full Python 3.15 suite: 220 passed, 17 skipped.
  • Cache-reset tests on Python 3.8: 2 passed.
  • git diff --check passed.

@15r10nk
15r10nk force-pushed the clear-source-lookup-caches branch from 0988ecf to 394f0c2 Compare November 26, 2026 03:18
Comment thread executing/executing.py
return result

@classmethod
def _clear_caches(cls, *, execution_cache_only: bool = False) -> None:

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is execution_cache_only only used in tests of execution_cache_only?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants