-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Try simple-minded call expression cache #19505
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
a48015a
f2d15c4
c836f53
32827a8
721facc
344a84a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -390,7 +390,7 @@ class Errors: | |
# in some cases to avoid reporting huge numbers of errors. | ||
seen_import_error = False | ||
|
||
_watchers: list[ErrorWatcher] = [] | ||
_watchers: list[ErrorWatcher] | ||
|
||
def __init__( | ||
self, | ||
|
@@ -421,6 +421,7 @@ def initialize(self) -> None: | |
self.scope = None | ||
self.target_module = None | ||
self.seen_import_error = False | ||
self._watchers = [] | ||
|
||
def reset(self) -> None: | ||
self.initialize() | ||
|
@@ -931,7 +932,8 @@ def prefer_simple_messages(self) -> bool: | |
if self.file in self.ignored_files: | ||
# Errors ignored, so no point generating fancy messages | ||
return True | ||
for _watcher in self._watchers: | ||
if self._watchers: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could you explain this change? Watchers used to be additive and that sounded reasonable to me... There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Previously, if any of the active watchers was ignoring errors, we could use simpler messages, but in presence of caching this is not valid anymore. For example, we can accept an expression when there is enclosing ignoring watcher, but then the caching watcher will record simple message, and if next time we, by chance, accept same expression in same type context, but without the ignoring watcher, an incorrect (i.e. way too terse) error message will be pulled from the cache. Without this change 6 tests fail because of terse/simplistic error messages are used. |
||
_watcher = self._watchers[-1] | ||
if _watcher._filter is True and _watcher._filtered is None: | ||
# Errors are filtered | ||
return True | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it be difficult to allow dicts and sets here? Inline dictionaries are relatively common and even heavier than lists, and sets just for consistency.
Also operator exprs can be really heavy (#14978) and are fundamentally similar to
CallExpr
, are they worth considering?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The problem with dicts/sets is that I see around 0.3% regression on self-check when I add them (but maybe this is just noise). My reasoning is that most code has a bunch of shallow dictionaries, and for those caching is just busy-work that will never be used (note caching is not free, since mypyc is slow on creating local type maps and watchers).
Anyway, I am open to considering more expression kinds to cache, but lets put those in separate PR(s).