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

non-recursive SameQ[] #1077

Merged
merged 9 commits into from
Aug 31, 2024
Merged

non-recursive SameQ[] #1077

merged 9 commits into from
Aug 31, 2024

Conversation

mmatera
Copy link
Contributor

@mmatera mmatera commented Aug 31, 2024

This PR is a proposal for a reimplementation of Expression.sameQ which uses a tree transversal iterative algorithm instead of recursion. Using this implementation, we avoid the recursion issue in the Pytests for Python 3.12.

I leave this as a draft for a while, in case someone else wants to propose a better solution.

@rocky
Copy link
Member

rocky commented Aug 31, 2024

@mmatera The idea is interesting and needed. I'd like look over this in more detail over the weekend and think about it. Thanks!

Copy link
Member

Choose a reason for hiding this comment

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

@mmatera Something in "make clean" is removing this. I haven't found where or fixed this.

Also it would be nice if we had a way to automatically generate ths.

@mmatera mmatera force-pushed the sameQ_nonrecursive branch from c9a8f62 to 16f2eda Compare August 31, 2024 11:10
@rocky rocky changed the title Same q nonrecursive non-recursive SameQ Aug 31, 2024
@rocky rocky changed the title non-recursive SameQ non-recursive SameQ[] Aug 31, 2024
@mmatera looked the code over and do not find anything wrong with it. 

I made some small changes to the docstring comment and addressed some of
the lint errors my editor is telling me about.

We can't use generators here since there we access and then "rewind"
sometimes. And this _is_ essentially a version without the tail
recursions. So I've removed the comments concerning doubt.

If you have the example that caused the failure on 3.12 without this
change, it would be interesting to benchmark just this test inside a
Mathics3 session to see if there's any difference in execution time.

Other comments I'll put in the specific code changes in this PR.

---------

Co-authored-by: Juan Mauricio Matera <[email protected]>
@rocky
Copy link
Member

rocky commented Aug 31, 2024

LGTM - merge when you are ready.

@mmatera
Copy link
Contributor Author

mmatera commented Aug 31, 2024

This is what I get when I run test/builtin/test_attributes.py

imagen

For some reason, it does not happen now in Github Actions

@mmatera mmatera marked this pull request as ready for review August 31, 2024 17:44
@mmatera mmatera merged commit 72b6d8f into master Aug 31, 2024
12 checks passed
@mmatera mmatera deleted the sameQ_nonrecursive branch August 31, 2024 17:44
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