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

fix same-object copies in deepcopy #131

Merged
merged 2 commits into from
Jan 28, 2024
Merged

Conversation

stev47
Copy link
Contributor

@stev47 stev47 commented Jan 24, 2024

Previously same-object references were not copied correctly and the following would fail.

x = Indices()
y = deepcopy((x, x))
@test y[1] === y[2]

In order to not copy the same object multiple times in deepcopy, an IdDict is passed to deepcopy_internal which should be used by implementations.
This commit makes use of that dictionary to store already copied objects and fix the above issue.

Also deepcopy_internal on Dictionary was superfluous and was removed along the way.

Previously same-object references were not copied correctly and the
following would fail.
```
x = Indices()
y = deepcopy((x, x))
@test y[1] === y[2]
```
In order to not copy the same object multiple times in `deepcopy`, an
`IdDict` is passed to `deepcopy_internal` which should be used by
implementations.
This commit makes use of that dictionary to store already copied objects
and fix the above issue.
Copy link

codecov bot commented Jan 27, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (0230039) 80.10% compared to head (a6e6ff2) 80.12%.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #131      +/-   ##
==========================================
+ Coverage   80.10%   80.12%   +0.02%     
==========================================
  Files          20       20              
  Lines        2357     2360       +3     
==========================================
+ Hits         1888     1891       +3     
  Misses        469      469              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Owner

@andyferris andyferris left a comment

Choose a reason for hiding this comment

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

Nice catch @stev47 - thank you!

@andyferris andyferris merged commit 9202350 into andyferris:master Jan 28, 2024
23 checks passed
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