-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
PERF: Fix performance regression in get_loc of IntervalIndex #51339
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 1 commit
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 |
---|---|---|
|
@@ -662,7 +662,9 @@ def _validate(cls, left, right, dtype: IntervalDtype) -> None: | |
msg = "left side of interval must be <= right side" | ||
raise ValueError(msg) | ||
|
||
def _shallow_copy(self: IntervalArrayT, left, right) -> IntervalArrayT: | ||
def _shallow_copy( | ||
self: IntervalArrayT, left, right, verify_integrity: bool = True | ||
) -> IntervalArrayT: | ||
""" | ||
Return a new IntervalArray with the replacement attributes | ||
|
||
|
@@ -675,7 +677,8 @@ def _shallow_copy(self: IntervalArrayT, left, right) -> IntervalArrayT: | |
""" | ||
dtype = IntervalDtype(left.dtype, closed=self.closed) | ||
left, right, dtype = self._ensure_simple_new_inputs(left, right, dtype=dtype) | ||
self._validate(left, right, dtype=dtype) | ||
if verify_integrity: | ||
self._validate(left, right, dtype=dtype) | ||
|
||
return self._simple_new(left, right, dtype=dtype) | ||
|
||
|
@@ -727,7 +730,7 @@ def __getitem__( | |
if np.ndim(left) > 1: | ||
# GH#30588 multi-dimensional indexer disallowed | ||
raise ValueError("multi-dimensional indexing not allowed") | ||
return self._shallow_copy(left, right) | ||
return self._shallow_copy(left, right, verify_integrity=False) | ||
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. couldnt we also skip _ensure_simple_new_inputs, i.e. just do
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. let's see if it works, probably not necessary |
||
|
||
def __setitem__(self, key, value) -> None: | ||
value_left, value_right = self._validate_setitem_value(value) | ||
|
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.
so is this still necessary?
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.
Not for this regression, but I think we should look through all usages to see if it's necessary everywhere