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

Optimize flatten/unflatten #12

Merged
merged 23 commits into from
Apr 13, 2023
Merged

Optimize flatten/unflatten #12

merged 23 commits into from
Apr 13, 2023

Conversation

cgarciae
Copy link
Owner

@cgarciae cgarciae commented Apr 11, 2023

Changes

  • Adds _pytree__node_fields static field that is calculated for all Pytrees after __init__.
  • Uses _pytree__node_fields to avoid sorting during tree_flatten.
  • Uses flatten_func from register_pytree_with_keys to speedup flattening when keys are not needed.

@codecov
Copy link

codecov bot commented Apr 11, 2023

Codecov Report

Merging #12 (279581c) into main (a4bc7a8) will decrease coverage by 1.14%.
The diff coverage is 92.45%.

@@            Coverage Diff             @@
##             main      #12      +/-   ##
==========================================
- Coverage   97.45%   96.32%   -1.14%     
==========================================
  Files           2        3       +1     
  Lines         118      136      +18     
==========================================
+ Hits          115      131      +16     
- Misses          3        5       +2     
Impacted Files Coverage Δ
simple_pytree/dataclass.py 90.00% <90.00%> (ø)
simple_pytree/pytree.py 97.32% <93.10%> (-0.07%) ⬇️
simple_pytree/__init__.py 100.00% <100.00%> (ø)

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@cgarciae cgarciae merged commit aa7e016 into main Apr 13, 2023
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.

1 participant