-
-
Notifications
You must be signed in to change notification settings - Fork 18.6k
ENH: propagating attrs always uses deepcopy #55314
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
Conversation
Importing stdlib
What is the preferred way in the project to handle this? |
Probably using |
cb34da5
to
33667a0
Compare
33667a0
to
554a764
Compare
Just a pre-commit check failing otherwise looks good |
554a764
to
fcde0aa
Compare
Always using a deepcopy prevents shared state and thus unintentional modification of the attrs of other objects. IMHO this safety has a higher priority than the slight performance cost of the deepcopy. The implementation now skips the copying if *attrs* are not used (i.e. an empty dict). This check takes only ~20ns. Thus, the attrs propagation mechanism has no performance impact if attrs are not used. Closes pandas-dev#54134.
fcde0aa
to
a62913f
Compare
Thanks @timhoffm |
This patch may have induced a performance regression. If it was a necessary behavior change, this may have been expected and everything is okay. Please check the links below. If any ASVs are parameterized, the combinations of parameters that a regression has been detected for appear as subbullets. Subsequent benchmarks may have skipped some commits. The link below lists the commits that are between the two benchmark runs where the regression was identified. |
I believe the detected changes come from this PR. The test uses Note also that the tests use The use of |
Always using a deepcopy prevents shared state and thus unintentional modification of the attrs of other objects. IMHO this safety has a higher priority than the slight performance cost of the deepcopy. The implementation now skips the copying if attrs are not used (i.e. an empty dict). This check takes only ~20ns. Thus, the attrs copy mechanism has no performance impact if attrs are not used.
copy.deepcopy()
doesn't deepcopy the metadata in.attrs
#54134doc/source/whatsnew/vX.X.X.rst
file if fixing a bug or adding a new feature.