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

symtable as a generic visitor #113

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

symtable as a generic visitor #113

wants to merge 1 commit into from

Conversation

s-cork
Copy link
Contributor

@s-cork s-cork commented Jul 31, 2021

The internals of each visitor are the same.

I skipped test 483 because the variables print and ZeroDivision switched places.
This was because the autogenerated ast visitor visits the orelse before the handlers (that's also what pypy's does).
whereas the cpython visitor visits the handlers before the orelse.

There were a few choices there.

  1. skip the test (t483.py)
  2. change the base generic visitor for visit_Try.
  3. change the SymbolTable visitor for visit_Try.

I went with 1. But 3 would also be good.

Bench marks are very slightly quicker for this branch vs master. But it's nothing to write home about.

@albertjan
Copy link
Member

Yeah I would've gone for 3 😄 looks cool though. Might make it harder to port newer version of cpython to this though 🤷

@s-cork
Copy link
Contributor Author

s-cork commented Aug 1, 2021

Possibly. But thinking about the update process, if we need to update I guess we'd look at the symtable diff in cpython, work out where the changes were made then map the changes to our implementation.

In both implementations there's still a one to one correspondence for mapping the changes. If say the case for functionDef changed then instead of going to the switch case we just go to the visit_functionDef method.

Would be worthy of a top level comment I think explaining that to our future selves.

Base automatically changed from generic_visitor to master August 9, 2021 13:55
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