Skip to content

Conversation

rhshadrach
Copy link
Member

@rhshadrach rhshadrach commented Jul 27, 2025

When we create a Series from an Index, it's zero copy which means that with CoW there are weak refs to the Index. Comparison of these weak refs uses Index.__eq__, which operates on the array (unlike Block.__eq__ which is merely is). This leads to failure in Series.replace.

Instead, we replace the equality checks with is, plus some additional logic for performance. I believe this is the only place where we are using __eq__ on these references.

@rhshadrach rhshadrach added this to the 3.0 milestone Jul 27, 2025
Copy link
Member

@phofl phofl left a comment

Choose a reason for hiding this comment

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

looks good to me

You are correct, this should be the only place where we check references for equality.

@rhshadrach rhshadrach requested a review from mroeschke July 27, 2025 14:03
@mroeschke mroeschke merged commit 8759c5d into pandas-dev:main Jul 28, 2025
43 checks passed
@mroeschke
Copy link
Member

Thanks @rhshadrach

@rhshadrach rhshadrach deleted the bug_cow_replace branch July 28, 2025 18:47
eicchen pushed a commit to eicchen/pandas that referenced this pull request Aug 19, 2025
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.

BUG: CoW - eq not implemented for <class 'pandas.core.internals.blocks.ExtensionBlock'>

3 participants