-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
modernize syntax in Timestamp #18327
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
Conversation
pandas/_libs/tslib.pyx
Outdated
@@ -92,6 +92,7 @@ from tslibs.nattype import NaT, nat_strings, iNaT | |||
from tslibs.nattype cimport _checknull_with_nat, NPY_NAT | |||
|
|||
|
|||
# TODO: Can this become a classmethod? |
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.
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.
no, see how its used, it is for compat on creating datetime, date, Timestamp
Codecov Report
@@ Coverage Diff @@
## master #18327 +/- ##
==========================================
- Coverage 91.38% 91.36% -0.02%
==========================================
Files 164 164
Lines 49780 49790 +10
==========================================
+ Hits 45491 45492 +1
- Misses 4289 4298 +9
Continue to review full report at Codecov.
|
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.
does this change any perf?
pandas/_libs/tslib.pyx
Outdated
@@ -92,6 +92,7 @@ from tslibs.nattype import NaT, nat_strings, iNaT | |||
from tslibs.nattype cimport _checknull_with_nat, NPY_NAT | |||
|
|||
|
|||
# TODO: Can this become a classmethod? |
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.
no, see how its used, it is for compat on creating datetime, date, Timestamp
pandas/_libs/tslib.pyx
Outdated
return '%s %s' % (self._date_repr, self._time_repr) | ||
@property | ||
def _repr_base(self): | ||
return '%s %s' % (self._date_repr, self._time_repr) |
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.
change what you can to use format syntax
I'll remove the comment, but I don't see why the compat usage affects the answer. There are a handful of classmethods that in principle should use |
I didn't benchmark it. The Using |
actually pls give this a quick benchmark, I recall this syntax as somewhat preferable, though that maybe outdated. |
Looks like noise:
and with affinity
|
your asv runs are still very wild. |
thanks |
Small cleanups to
Timestamp
+_Timestamp
, use@property
instead of older syntax.The only substantive change is in
__add__
, whereresult = Timestamp(normalize_date(result))
is changed toresult = result.normalize()
. The latter has the benefitsis robust for tzaware timestamps,
does not require
normalize_date
in the namespace, so after thisTimestamp
+_Timestamp
can be cut/paste into a newtslibs.timestamps
andis robust to subclassing of
Timestamp
.