-
Notifications
You must be signed in to change notification settings - Fork 18
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
Add parsing support for Interval #128
Conversation
I know that LibPQ rolled its own interval parsing code so I took a look at it to ensure this PR works nicely there. The only issue I see is that LibPQ wants to call it's own parsing function. I'll try to support that. |
Codecov Report
@@ Coverage Diff @@
## master #128 +/- ##
==========================================
+ Coverage 73.92% 74.72% +0.80%
==========================================
Files 9 10 +1
Lines 441 455 +14
==========================================
+ Hits 326 340 +14
Misses 115 115
Continue to review full report at Codecov.
|
Are regexes in Julia inherently slow? |
Just needs a version bump, I assume we would want to bring along a few of the other CRs across the line before making a new release though. |
The issue isn't that regexes in Julia are slow but rather that regexes in general are slower than if you write a custom lower level parser. This is mostly due to the flexibility of regex and backtracking. |
For GitHub packages I've been bumping the version number outside of the PRs which avoids confusion on whether it has already been bumped. This will be 1.4.0 and I'll probably tag it soon after. |
Yeah that's what I meant, @iamed2 converted me into this practice :P |
Quick aside. I benchmarked using possessive quantifiers to prevent backtracking and there was no performance improvement in this case |
IMO this should support ".." and we should continue to print "..". This is the standard notation for intervals in Julia. |
I'll make this change. I was starting to worry about how this could break tests which check printing. |
Allows for round-trip parsing of printed intervals. Note I believe the original reason we printed with `..` was to avoid any confusion between a closed-interval and a vector (e.g. `[1, 2]`)
This reverts commit dd92aa5.
Parsing now supports both |
There's room for performance improvements here. I'll make a separate issue about that to be done later and get this feature out now |
Issue about improving performance: #131. The last round of regex changes didn't seem to negatively impact performance: julia> @btime parse(Interval{Int}, "[1,2)")
734.102 ns (13 allocations: 656 bytes)
Interval{Int64,Closed,Open}(1, 2) |
Adds parsing support for
Interval{T}
. I ended up just using comma as the parsing delimiter here as I expect it's the syntax most people would expect. Because this PR currently only supports the comma delimiter I changed the printing of intervals to also use a comma. Using a comma for the delimiter when printing has a chance of having a user think that a printed closed-interval is actually a Vector (e.g.[1, 2]
). We could work around this by leaving printing using..
and just support both delimiters when parsing.The parsing performance seems pretty good here despite using a regex. I expect we can improve the parsing performance further but I'm happy with this for now:
Fixes #116.
Update: Both parsing of delimiters
..
and,
are supported now and printing has been left unchanged.