-
-
Notifications
You must be signed in to change notification settings - Fork 18.3k
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
BUG: Arithmetic inplace ops not respecting CoW #51403
Conversation
pandas/core/generic.py
Outdated
if ( | ||
self.ndim == 1 | ||
and result._indexed_same(self) | ||
and is_dtype_equal(result.dtype, self.dtype) | ||
and not ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could use iloc instead of checking for references, but would probably cost performance?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I think it is fine to use the manager method here (we can de-privatize if needed at some point)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, if you want to use an existing manager method that already takes care of this, on a SingleBlockManager, that would actually be self._mgr.setitem_inplace(slice(None), result._values)
That should translate to exactly the same (it only does an additional np_can_hold_element
check, but I assume that should be cheap if the dtypes are equal, which is already checked above)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like this, switched over.
greenish |
doc/source/whatsnew/vX.X.X.rst
file if fixing a bug or adding a new feature.We should add tests for all op-possibilities in a follow up