Skip to content

CoW: Copy less in replace implementation with listlikes #54116

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 5 commits into from
Aug 11, 2023

Conversation

phofl
Copy link
Member

@phofl phofl commented Jul 13, 2023

  • closes #xxxx (Replace xxxx with the GitHub issue number)
  • Tests added and passed if fixing a bug or adding a new feature
  • All code checks passed.
  • Added type annotations to new arguments/methods/functions.
  • Added an entry in the latest doc/source/whatsnew/vX.X.X.rst file if fixing a bug or adding a new feature.

This is the best version I could come up with

@jorisvandenbossche
Copy link
Member

This is the best version I could come up with

General concern: do we think this is worth the added complexity? (and the replace code is already really complex ..)

The case it is trying to solve is that if you do an inplace replace with a list like, this could be done actually inplace (if there are no other refs to start with), while now it always makes a copy?

@phofl
Copy link
Member Author

phofl commented Jul 17, 2023

This is generally for listlike replace ops, not only inplace. The current implementation copies for every pass, which is too slow imo

@jorisvandenbossche
Copy link
Member

The current implementation copies for every pass, which is too slow imo

And does that only happen under CoW, or also in the default?

@phofl
Copy link
Member Author

phofl commented Jul 17, 2023

Both as far as I know, but we should fix this anyway

# Conflicts:
#	pandas/core/internals/blocks.py
#	pandas/tests/copy_view/test_replace.py
@phofl phofl added this to the 2.1 milestone Aug 11, 2023
@phofl
Copy link
Member Author

phofl commented Aug 11, 2023

Also agreed to merge

@phofl phofl merged commit cdb9cff into pandas-dev:main Aug 11, 2023
@phofl phofl deleted the cow_replace_list branch August 11, 2023 09:17
mroeschke pushed a commit to mroeschke/pandas that referenced this pull request Aug 18, 2023
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