Skip to content

ENH: Add lazy copy to pipe #50567

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

Merged
merged 4 commits into from
Jan 6, 2023
Merged

ENH: Add lazy copy to pipe #50567

merged 4 commits into from
Jan 6, 2023

Conversation

phofl
Copy link
Member

@phofl phofl commented Jan 4, 2023

Comment on lines 5774 to 5776
result = common.pipe(self, func, *args, **kwargs)
if _using_copy_on_write():
return result.copy(deep=None)
Copy link
Member

Choose a reason for hiding this comment

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

Should we pass in self.copy(deep=None) to the pipe, instead of shallow copying the result?

Or do we have guarantees at the moment about that a piped function can mutate the dataframe inplace?

Copy link
Member Author

Choose a reason for hiding this comment

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

Good point, this should be the other way round, will adjust accordingly and add tests

Copy link
Member Author

Choose a reason for hiding this comment

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

Moved and added another test modifying the object inplace

@phofl phofl merged commit 18c4365 into pandas-dev:main Jan 6, 2023
@phofl phofl deleted the cow_pipe branch February 11, 2023 11:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants