-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
CLN: tslibs.parsing #30394
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
CLN: tslibs.parsing #30394
Conversation
pandas/_libs/tslibs/parsing.pyx
Outdated
object reso = None | ||
dict repl = {} | ||
|
||
fobj = StringIO(str(timestr)) | ||
res = DEFAULTPARSER._parse(fobj, dayfirst=dayfirst, yearfirst=yearfirst) | ||
res = DEFAULTPARSER._parse(timestr, dayfirst=dayfirst, yearfirst=yearfirst) | ||
|
||
# dateutil 2.2 compat |
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.
Do we need this if
statement anymore? Our min dateutil
version is 2.6.1 now
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.
probably not. will check locally and do in follow-up
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.
actually, will do here since theres another typo to fix
@@ -1,6 +1,6 @@ | |||
# -*- coding: utf-8 -*- | |||
|
|||
cpdef object get_rule_month(object source, object default=*) | |||
cpdef str get_rule_month(object source, str default=*) |
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.
Do we get any performance boosts from the stronger types here?
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.
None that I can detect with timeit
pandas/_libs/tslibs/parsing.pyx
Outdated
|
||
Returns: | ||
-------- | ||
datetime, resolution | ||
datetime or Nont |
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.
datetime or Nont | |
datetime or None |
@@ -1191,12 +1191,15 @@ cdef int64_t period_ordinal_to_dt64(int64_t ordinal, int freq) except? -1: | |||
return dtstruct_to_dt64(&dts) | |||
|
|||
|
|||
def period_format(int64_t value, int freq, object fmt=None): | |||
cdef str period_format(int64_t value, int freq, object fmt=None): |
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 sure the extent of Cython annotation support but Optional[Union[str, bytes]]
would be nice for fmt
here if possible
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.
Cython annotation support but Optional[Union[str, bytes]]
I think that can be done, but it wouldn't resemble the pure-py annotation at all, so would be more confusing than helpful. In the next pass I'll see if I can get rid of the str cases, at which point it will be easier
@@ -1097,6 +1097,8 @@ def __call__(self, x, pos=0): | |||
return "" | |||
else: | |||
fmt = self.formatdict.pop(x, "") | |||
if isinstance(fmt, np.bytes_): |
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.
Is this supposed to be in this PR?
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.
Yes, without it the call to strftime below fails bc strftime is now typed to want a str
lgtm to me; @WillAyd & @mroeschke make some good points. |
Thanks @jbrockmendel |
Non-segfault-related pieces broken off from #30374. Fix a (not-reachable-but-thats-another-conversation) tzinfo check closing #22234.
De-duplicates get_rule_month in tslibs.frequencies and tslibs.parsing
pythonizes a PyUnicode_Join usage because cython does that optimization already.