Skip to content
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

Pass 'parents' as a parameter when walking the tree #224

Merged
merged 1 commit into from
Oct 22, 2023

Conversation

jparise
Copy link
Member

@jparise jparise commented Oct 22, 2023

Rather than storing the 'parents' deque as an instance attribute, pass it as a parameter as we walk the tree.

This gives us more explicit control of this stack's lifetime (and no more mutable state on the object itself), and it allows us to better restrict the typed interface we present to visitor methods (Iterable).

It also might result in a micro-optimization because read a parameter value is less involved (faster) than loading an instance attribute, but that isn't the goal of this change.

Rather than storing the 'parents' deque as an instance attribute,
pass it as a parameter as we walk the tree.

This gives us more explicit control of this stack's lifetime (and no
more mutable state on the object itself), and it allows us to better
restrict the typed interface we present to visitor methods (`Iterable`).

It also might result in a micro-optimization because read a parameter
value is less involved (faster) than loading an instance attribute, but
that isn't the goal of this change.
@jparise jparise merged commit 01df3f3 into PyCQA:main Oct 22, 2023
6 checks passed
@jparise jparise deleted the parents branch October 22, 2023 01:54
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