-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
ENH: Improve ref-tracking for group keys #51442
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
Changes from 3 commits
91d8acc
fb7915a
c2c77c6
0873d50
b7270b4
721dcc1
7f9effb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,6 +11,7 @@ | |
final, | ||
) | ||
import warnings | ||
import weakref | ||
|
||
import numpy as np | ||
|
||
|
@@ -947,9 +948,13 @@ def is_in_obj(gpr) -> bool: | |
# For the CoW case, we need an equality check as the identity check | ||
# no longer works (each Series from column access is a new object) | ||
try: | ||
return gpr.equals(obj[gpr.name]) | ||
obj_gpr_column = obj[gpr.name] | ||
except (AttributeError, KeyError, IndexError, InvalidIndexError): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You can remove the AttributeError now, I think ( There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Correct, thx |
||
return False | ||
if isinstance(gpr, Series) and isinstance(obj_gpr_column, Series): | ||
ref = weakref.ref(obj_gpr_column._mgr.blocks[0]) | ||
return ref in gpr._mgr.blocks[0].refs.referenced_blocks | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So if you create multiple times a weakref to the same object, this is always the same (i.e. identical) weakref object? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yep, that's how it is documented (https://docs.python.org/3/library/weakref.html#weakref.ref). Did some basic checks with out blocks and it works as I would have expected |
||
return False | ||
try: | ||
return gpr is obj[gpr.name] | ||
except (KeyError, IndexError, InvalidIndexError): | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you update this comment?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done