Skip to content

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

Merged
merged 6 commits into from
Dec 23, 2019
Merged

CLN: tslibs.parsing #30394

merged 6 commits into from
Dec 23, 2019

Conversation

jbrockmendel
Copy link
Member

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.

@gfyoung gfyoung added Clean Timezones Timezone data dtype labels Dec 22, 2019
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
Copy link
Member

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

Copy link
Member Author

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

Copy link
Member Author

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=*)
Copy link
Member

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?

Copy link
Member Author

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


Returns:
--------
datetime, resolution
datetime or Nont
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
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):
Copy link
Member

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

Copy link
Member Author

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_):
Copy link
Member

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?

Copy link
Member Author

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

@jreback jreback added this to the 1.0 milestone Dec 23, 2019
@jreback
Copy link
Contributor

jreback commented Dec 23, 2019

lgtm to me; @WillAyd & @mroeschke make some good points.

@WillAyd WillAyd merged commit db62039 into pandas-dev:master Dec 23, 2019
@WillAyd
Copy link
Member

WillAyd commented Dec 23, 2019

Thanks @jbrockmendel

@jbrockmendel jbrockmendel deleted the types-tslibs branch December 23, 2019 18:38
AlexKirko pushed a commit to AlexKirko/pandas that referenced this pull request Dec 29, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Clean Timezones Timezone data dtype
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Incorrect tzinfo check in tslibs.parsing
5 participants