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

Version of TopologicalSorter without error checking #1158

Closed
jakelishman opened this issue Apr 5, 2024 · 0 comments · Fixed by #1160
Closed

Version of TopologicalSorter without error checking #1158

jakelishman opened this issue Apr 5, 2024 · 0 comments · Fixed by #1160

Comments

@jakelishman
Copy link
Member

What is the expected enhancement?

At the moment, TopologicalSorter hashes every index both as it goes through get_ready and as it's returned to done and builds up a hashmap of the size of all visited nodes, only for the purposes of emitting Python-space errors if the user does something incorrectly. None of "putting in an invalid node", "putting in an unready node" and "putting in an already done node" should cause a Rust-space panic (though will ofc cause the algorithm to give nonsensical results).

It'd be nice for performance if there was a way to use a TopologicalSorter that didn't have that memory and runtime overhead. Philosophically, I'd like it if it wasn't there at all, so there's two separate Rust pyclasses, one with error-checking compiled in and one without (and new just builds the correct one), but I think most of my concern would be addressed by making TopologicalSorter::node2state an Option and deciding whether to check it at runtime.

Again, I'll make the PR if there's a chosen direction.

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 a pull request may close this issue.

1 participant