Skip to content

AstInterpreter: Slight Performance Improvement#15754

Merged
bonzini merged 1 commit into
mesonbuild:masterfrom
Volker-Weissmann:create_uv
Apr 28, 2026
Merged

AstInterpreter: Slight Performance Improvement#15754
bonzini merged 1 commit into
mesonbuild:masterfrom
Volker-Weissmann:create_uv

Conversation

@Volker-Weissmann

Copy link
Copy Markdown
Contributor

See discussion at #15743

Comment thread mesonbuild/ast/interpreter.py Outdated
if self.tainted:
return UnknownValue()
else:
return UndefinedVariable()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Better:

        for nesting, value in reversed(self.cur_assignments[var_name]):
            if len(self.nesting) >= len(nesting) and self.nesting[:len(nesting)] == nesting:
                return value
        if self.tainted:
            return UnknownValue()
        return UndefinedVariable()

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

You're right, I took your code: 7f81e91

Creating an Object of type `UndefinedVariable` takes longer than
assigning `None`, and `get_cur_value_if_defined` is executed a lot of
times when you run `meson configure` without a build dir.

See also: mesonbuild#15743
@Volker-Weissmann
Volker-Weissmann marked this pull request as ready for review April 27, 2026 16:02
@bonzini
bonzini merged commit 07c0aa7 into mesonbuild:master Apr 28, 2026
29 of 30 checks passed
@bonzini bonzini added this to the 1.11.2 milestone Apr 28, 2026
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.

3 participants