Skip to content

Conversation

@jbrockmendel
Copy link
Contributor

Replaces #698.

At the moment _ymd.resolve_ymd can ignore ystridx and dstridx in some corner cases. This PR has resolve_ymd check if enough of [ystridx, mstridx, dstridx] have been specified to uniquely pin down (year, month, day), and if so, use those instead of other heuristics.

Edits resolve_ymd to prevent deleting an element in-place, which makes step-through debugging more difficult.

Closes #687

Pull Request Checklist

  • Changes have tests
  • Authors have been added to AUTHORS.md
  • News fragment added in changelog.d. See CONTRIBUTING.md for details

@pganssle
Copy link
Member

This more or less looks good to me, though it does seem like a concerning amount of overhead to fix this very specific corner case. Not a big deal though.

@jbrockmendel
Copy link
Contributor Author

though it does seem like a concerning amount of overhead to fix this very specific corner case

Yah, the more specific fix would have been at L498 to check self.ystridx in addition to self.mstridx, but I didn't want to get to a situation where we're checking for ystridx in only one of the many if/else branches, not checking dstridx at all, etc.

The change from 501-511 could be considered orthogonal.

Copy link
Member

@pganssle pganssle left a comment

Choose a reason for hiding this comment

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

Some minor performance concerns, but nothing blocking. l've restructured the code a bit to hopefully improve performance, and I'd say it's ready to merge now. @jbrockmendel Any objections to my changes?

@jbrockmendel
Copy link
Contributor Author

Looks fine. Is the perf really affected? If so then constructing strids once and passing it as an arg (instead of constructing it twice like in the previous version) makes sense.

Aesthetically I like the {"y": self.stridx, ...} better than the (("y", self.ystridx), ...) but that's not a big deal.

@pganssle
Copy link
Member

pganssle commented May 7, 2018

I doubt it will really make a major difference in the long run given that the parser is not amazingly performant to start with, but I'd like to minimize the performance impact since this particular bug is for such an incredibly niche problem.

From micro-benchmarks I would estimate I saved a few microseconds by organizing it this way.

@pganssle pganssle merged commit 99d0b76 into dateutil:master May 7, 2018
@pganssle pganssle mentioned this pull request May 9, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Parser error with unambiguous date in year 31

2 participants