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

Scope and Binding IDs #3572

Merged
merged 2 commits into from
Mar 17, 2023
Merged

Scope and Binding IDs #3572

merged 2 commits into from
Mar 17, 2023

Conversation

MichaReiser
Copy link
Member

@MichaReiser MichaReiser commented Mar 17, 2023

This PR introduces the new ScopeId and BindingId types instead of using the generic usize type.

Using a specific type allows us to enforce that bindings and scopes can only be indexed with the corresponding id-types, reducing the risk that they get mixed up. To do this, I had to introduce new Scopes, Bindings and ScopeStack wrapper types.

This PR removes the AtomicUsize that computes the next scope id and instead uses scopes.len() to compute the next id.

@MichaReiser
Copy link
Member Author

MichaReiser commented Mar 17, 2023

Current dependencies on/for this PR:

This comment was auto-generated by Graphite.

@MichaReiser MichaReiser force-pushed the scope-banding-id branch 2 times, most recently from 919ef5e to e5f64ce Compare March 17, 2023 10:57
@MichaReiser MichaReiser marked this pull request as ready for review March 17, 2023 10:57
@MichaReiser MichaReiser added the internal An internal refactor or improvement label Mar 17, 2023
@@ -295,3 +304,132 @@ impl<'a> Context<'a> {
}
}
}

/// The scopes of a program indexed by [`ScopeId`]
Copy link
Member Author

Choose a reason for hiding this comment

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

I moved all these types to a scope.rs in the following PR

@github-actions
Copy link
Contributor

github-actions bot commented Mar 17, 2023

PR Check Results

Ecosystem

✅ ecosystem check detected no changes.

Benchmark

Linux

group                        main                                   pr
-----                        ----                                   --
linter/large/dataset.py      1.01      8.6±0.06ms     4.7 MB/sec    1.00      8.5±0.07ms     4.8 MB/sec
linter/numpy/ctypeslib.py    1.03      2.3±0.01ms   152.3 MB/sec    1.00      2.2±0.01ms   157.5 MB/sec
linter/numpy/globals.py      1.03   1134.6±6.01µs   157.1 MB/sec    1.00   1104.3±3.29µs   161.4 MB/sec
linter/pydantic/types.py     1.01      3.9±0.02ms     6.5 MB/sec    1.00      3.9±0.01ms     6.6 MB/sec

Windows

group                        main                                   pr
-----                        ----                                   --
linter/large/dataset.py      1.00      8.8±0.09ms     4.6 MB/sec    1.01      8.9±0.20ms     4.6 MB/sec
linter/numpy/ctypeslib.py    1.00      2.3±0.03ms   149.0 MB/sec    1.03      2.4±0.03ms   145.4 MB/sec
linter/numpy/globals.py      1.00  1177.3±26.31µs   151.4 MB/sec    1.01  1193.0±23.48µs   149.4 MB/sec
linter/pydantic/types.py     1.00      4.1±0.08ms     6.2 MB/sec    1.01      4.1±0.09ms     6.2 MB/sec

Copy link
Member

@charliermarsh charliermarsh left a comment

Choose a reason for hiding this comment

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

Great change, big improvement.

@MichaReiser MichaReiser merged commit 92179e6 into main Mar 17, 2023
@MichaReiser MichaReiser deleted the scope-banding-id branch March 17, 2023 16:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
internal An internal refactor or improvement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants