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
allow convert from RegexMatch to Dict/NamedTuple #50988
Conversation
bump |
bump... |
Let's see if we can find a reviewer for this. |
Bump... |
bump... |
Let's discuss on the next triage call. cc @LilithHafner |
triage is cool with this. (both NamedTuple and Dict) The fact that the dual indexing lines up is a nice factor. |
Triage approves. (Confusing title was causing much delay unfortunately; have edited for clarity: this PR allows converting RegexMatch objects to NamedTuples and Dicts.) While it's true that converting to NamedTuple goes from value domain to type domain, it was observed that very often the regex object is a compile-time constant and it would actually be possible to optimize the NamedTuple construction to specialize on the names specified in the regex string macro call. @ericphanson pointed out that this might require capturing names in the RegexMatch object, but I'm not entirely sure if that's necessary with constant propagation. The point is not that we even need that optimization, but that it is in principle possible, which weakens the performance argument: converting from statically known regex to NamedTuple is not inherently slow, it just happens to be slow. Conversion to Dict seems uncontroversial. |
Still needs docs and news, then should be good to merge! |
Co-authored-by: Jeff Bezanson <jeff.bezanson@gmail.com>
Co-authored-by: Jeff Bezanson <jeff.bezanson@gmail.com>
Co-authored-by: Jeff Bezanson <jeff.bezanson@gmail.com>
Co-authored-by: Jeff Bezanson <jeff.bezanson@gmail.com>
Co-authored-by: Jeff Bezanson <jeff.bezanson@gmail.com>
Co-authored-by: Jeff Bezanson <jeff.bezanson@gmail.com>
Note we should not use "convert" terminology, to avoid confusion with |
Bump. This is ready to go, just needs a rebase. |
The conflict appears to be minor in NEWS.md |
I wasn't really sure if this step is something I need to do, or it is resolved almost automatically by the person merging the PR. Clicked resolve now, sorry if this misunderstanding led to a delay. |
It can be done by people with commit rights but requires the "maintainers can edit" option to be enabled, which I don't think it was for this |
Added implementation + tests, will add to docs if ok --------- Co-authored-by: Dilum Aluthge <dilum@aluthge.com> Co-authored-by: Jeff Bezanson <jeff.bezanson@gmail.com>
Added implementation + tests, will add to docs if ok --------- Co-authored-by: Dilum Aluthge <dilum@aluthge.com> Co-authored-by: Jeff Bezanson <jeff.bezanson@gmail.com>
Added implementation + tests, will add to docs if ok