-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
have _NaT subclass datetime directly #17793
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
Codecov Report
@@ Coverage Diff @@
## master #17793 +/- ##
==========================================
- Coverage 91.24% 91.22% -0.02%
==========================================
Files 163 163
Lines 49918 49918
==========================================
- Hits 45546 45537 -9
- Misses 4372 4381 +9
Continue to review full report at Codecov.
|
Codecov Report
@@ Coverage Diff @@
## master #17793 +/- ##
==========================================
- Coverage 91.24% 91.23% -0.02%
==========================================
Files 163 163
Lines 50168 50168
==========================================
- Hits 45777 45769 -8
- Misses 4391 4399 +8
Continue to review full report at Codecov.
|
going to wait on this till after we release 0.21.0 |
note that we might as well NOT subclass datetime at all! its a bit tricky though you would have to implement a metaclass so isinstance check would work (IOW you still want this to be a datetime). but that makes this simpler. |
My impression is that metaclasses in cython are finicky. That might be out of date.
Sounds good. In the interim I'll try to finish off the |
i would like to see this not subclass datetime you can dig into the CPython source to see how this is done |
I'll put looking into this on the tslibs todo list.
At the moment |
hmm maybe we don’t event need to make isinstance be true; so try not subclassing datetime and see what breaks; |
Do you mind saving that for a follow-up? This has been added to #17652. |
ok this lgtm. |
@jbrockmendel if you want to merge in different order that my arbitrary one :> lmk. just ping which one should go first. |
I'll be happy with any order; go nuts. Way to be a closer today!
…Sent from my iPhone
On Oct 27, 2017, at 5:01 PM, Jeff Reback ***@***.***> wrote:
@jbrockmendel if you want to merge in different order that my arbitrary one :> lmk. just ping which one should go first.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or mute the thread.
|
need’s rebase |
thanks! |
The main change made by this PR is to have
_NaT
subclassdatetime
directly instead of subclassing_Timestamp
. Everything else is just to preserve the current behavior.Why you ask? Because once this is OKed, the entire
NaT
machinery can be cut/paste into a stand-alone module whose only intra-pandas dependency isutil
.The only non-trivial behavior is in
__add__
and__sub__
, where currently_NaT
dispatches to_Timestamp
for a few cases. This PR re-implements those cases directly in_NaT
. While that does mean a small amount of repetition, it opens up the possibility of using@cython.final
for potential optimization in_Timestamp.__add__/__sub__
.NaTType.to_datetime
could use_make_nat_func
if we were OK with it not producing the same warning asTimestamp.to_datetime
.git diff upstream/master -u -- "*.py" | flake8 --diff