Skip to content

Conversation

jbrockmendel
Copy link
Member

  • 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.

Can do a little bit more along these lines, but am splitting it into smaller chunks bc the refactored helpers are not perfect cut/paste.

@mroeschke mroeschke added Refactor Internal refactoring of code Copy / view semantics labels Jun 27, 2023
@mroeschke mroeschke added this to the 2.1 milestone Jun 27, 2023
@mroeschke mroeschke merged commit 6c75f4f into pandas-dev:main Jun 27, 2023
@mroeschke
Copy link
Member

Thanks @jbrockmendel

@jbrockmendel jbrockmendel deleted the ref-has_refs branch June 27, 2023 17:23
def _maybe_copy(self, using_cow: bool, inplace: bool) -> Self:
if using_cow and inplace:
deep = self.refs.has_reference()
blk = self.copy(deep=deep)
Copy link
Member

Choose a reason for hiding this comment

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

Just a general note here (it's not a problem right now): this could have side effects, creating a shallow copy of the block sets up another reference, which will yield True for blk.refs.has_reference() and self.refs.has_reference(), so have to be a bit careful when using

@phofl
Copy link
Member

phofl commented Jun 28, 2023

Thx for cleaning this up!

Daquisu pushed a commit to Daquisu/pandas that referenced this pull request Jul 8, 2023
* REF: refactor out Block helpers for CoW

* REF: de-duplicate helpers

* De-duplicate helper, revert _replace_coerce edits
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Copy / view semantics Refactor Internal refactoring of code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants