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

feat: implement safer hash #106

Merged
merged 8 commits into from
Jul 11, 2022
Merged

feat: implement safer hash #106

merged 8 commits into from
Jul 11, 2022

Conversation

redeboer
Copy link
Member

@redeboer redeboer commented Jul 11, 2022

Closes #41

With this PR, the hash of a sympy.Expr is generated faster and more safely once you set PYTHONHASHSEED to a specific value (see sympy/sympy#14835 (comment)). It is set to 0 by default in Conda's polarization environment (regenerate it with conda env create --force).

The tests assert that the new hash method is indeed unique for different symbol assumptions, but that the speed-up is not as large as anticipated. Hashing the 'folded' $\alpha_x$ expression for the default model:

  • 1.45 s ± 13 ms with unsafe hash
  • 1.05 s ± 43 ms with PYTHONHASHSEED=0

Other improvements:

  • Implemented logging hierarchy, see feat: implement logging hierarchy tensorwaves#453
  • The SymPy cache directory is now located under the to src by default in, so that it is more centrally available. (Note that this may cause problems in system-wide installs if admin rights are required.)

@redeboer redeboer added the ✨ Feature New feature added to the package label Jul 11, 2022
@redeboer redeboer self-assigned this Jul 11, 2022
@redeboer redeboer changed the title Faster hash feat: implement safer hash Jul 11, 2022
@redeboer redeboer merged commit fdedd49 into main Jul 11, 2022
@redeboer redeboer deleted the faster-hash branch July 11, 2022 08:34
redeboer added a commit that referenced this pull request Jul 12, 2022
Seems that the hash method from #106 is instable: the `.sympy-cache`
directory just keeps growing on each run of the uncertainties notebook.
redeboer added a commit that referenced this pull request Aug 17, 2022
* docs: add tip about `PYTHONHASHSEED`
* feat: implement logging hierarchy
* feat: warn if using unsafe hash
* refactor: move default sympy cache directory to `src`
@redeboer redeboer added this to the 0.0.1 milestone Sep 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
✨ Feature New feature added to the package
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Improve SHA256 hash for expressions
1 participant