Skip to content

Conversation

@mroeschke
Copy link
Member

A change to make it more explicit internally when we need to deep vs shallow copy a Block or Manager. Keeps the current behavior

@mroeschke mroeschke added this to the 3.0 milestone Nov 3, 2025
@mroeschke mroeschke added the Clean label Nov 3, 2025
new_axes = [copy_func(ax) for ax in self.axes]
else:
new_axes = [ax.view() for ax in self.axes]
new_axes = [ax.view() for ax in self.axes]
Copy link
Member

Choose a reason for hiding this comment

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

Reason that this is removed?

I know that an Index is generally immutable so the difference between view or actual copy is not relevant when it comes to the data, but we still some mutable attributes

Copy link
Member Author

Choose a reason for hiding this comment

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

deep="all" is not passed anymore AFAICT, so copy_func also becomes [ax.view() for ax in self.axes]. Should I change the view to copy to be safe?

Copy link
Member

Choose a reason for hiding this comment

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

Ah, sorry, missed the fact that the copy() call was only done for deep="all" ..

Yes, I would expect that we actually copy the indices in case of a deep=True

Copy link
Member

Choose a reason for hiding this comment

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

Hmm, it seems we have some tests that verify the shallow-ness of the copy (checking identity)

Copy link
Member Author

Choose a reason for hiding this comment

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

Ah darn. I'll leave a TODO comment here and just swap back to the existing behavior since this PR is just meant to not change behavior.

@mroeschke mroeschke merged commit 08c2c0d into pandas-dev:main Nov 5, 2025
42 checks passed
@mroeschke mroeschke deleted the ref/copy/deep_kw_only branch November 5, 2025 21:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants