Skip to content
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

TYP: datetimelike #38307

Merged
merged 1 commit into from
Dec 7, 2020
Merged

TYP: datetimelike #38307

merged 1 commit into from
Dec 7, 2020

Conversation

jbrockmendel
Copy link
Member

use np.putmask in a few places, as it is appreciably more performant than __setitem__

@@ -755,28 +760,30 @@ def isin(self, values) -> np.ndarray:
# ------------------------------------------------------------------
# Null Handling

def isna(self):
def isna(self) -> np.ndarray:
Copy link
Contributor

Choose a reason for hiding this comment

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

we dont' have the typing ability to do np.ndarray[bool] yet right?

Copy link
Member Author

Choose a reason for hiding this comment

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

not yet, correct

Copy link
Member

Choose a reason for hiding this comment

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

looks like will be in numpy 1.21 numpy/numpy#17719

@@ -996,7 +1006,7 @@ def _add_timedeltalike_scalar(self, other):
if isna(other):
# i.e np.timedelta64("NaT"), not recognized by delta_to_nanoseconds
new_values = np.empty(self.shape, dtype="i8")
new_values[:] = iNaT
new_values.fill(iNaT)
Copy link
Contributor

Choose a reason for hiding this comment

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

can use np.full here

Copy link
Contributor

Choose a reason for hiding this comment

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

followon ok too (as many places where this is done), though prob easy to do here

Copy link
Member Author

Choose a reason for hiding this comment

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

yah, we use .fill way more often, to the point that i sometimes forget that np.full is a thing

@jreback jreback added Datetime Datetime data dtype Typing type annotations, mypy/pyright type checking labels Dec 7, 2020
@jreback jreback added this to the 1.2 milestone Dec 7, 2020
@jreback
Copy link
Contributor

jreback commented Dec 7, 2020

might actually be some perf boosts here due to using putmask

@jbrockmendel
Copy link
Member Author

might actually be some perf boosts here due to using putmask

yep thats the idea

@jreback jreback merged commit 862cd05 into pandas-dev:master Dec 7, 2020
@jreback
Copy link
Contributor

jreback commented Dec 7, 2020

thanks

@jbrockmendel jbrockmendel deleted the typ-dtl branch December 7, 2020 20:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Datetime Datetime data dtype Typing type annotations, mypy/pyright type checking
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants