bpo-42128: Add __match_args__ to structseq-based classes#24732
Conversation
brandtbucher
left a comment
There was a problem hiding this comment.
Thanks Pablo!
Should we have a test for a structseq with unnamed fields? Asserting that os.stat_result.__match_args__ is expected should do it.
Sorry, something went wrong.
Done in 40bf3b7 |
Sorry, something went wrong.
|
Looking a bit closer... should we limit this to only Plus, we can always extend it later if it turns out to be an unnecessary limitation. |
Sorry, something went wrong.
Good point! I agree with that. I have pushed a new commit with this limitation. |
Sorry, something went wrong.
brandtbucher
left a comment
There was a problem hiding this comment.
Looks good to me!
The only improvement I might suggest is building up a list, then converting it to a tuple (or creating a tuple and shrinking it later with _PyTuple_Resize). That way we only need to loop once.
Sorry, something went wrong.
I considered that, but I think the code would be harder to read because appending to the list can fail on every iteration and we also need to covert the list to a tuple that can also fail. Also it will be less efficient so I decided with the current approach. I can do the resize approach, that will be cleaner. |
Sorry, something went wrong.
Done |
Sorry, something went wrong.
https://bugs.python.org/issue42128