| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
There was a problem hiding this comment.
I am surprised to see a correct complex C code from a new contributor. It is not easy to write all these error checks and decrefs on the first version.
The implementation creates arguments (a tuple and a dict) for __new__() and calls it. It is not the most efficient way, because it creates intermediate tuple and dict and can create string keys for name-only fields multiple times, but it works, and performance is not critical. I'm just wondering, whether it was your first idea or you considered other approaches and they turned out more complex? Did you try to create a new instance with PyStructSequence_New(), then copy ob_items from old structure to the new, then iterate the kwargs dict in one pass and patch ob_items? It looks simpler to me, but I may have missed some details.
Sorry, something went wrong.
@serhiy-storchaka My first thought is to create a copy of the current structseq and then replace the new values from kwargs. But I found it is kind of complex to handle the unnamed fields. Then I implement it with a similar structure to the __reduce__() implementation. I will refactor it with the former implementation since we have disabled the support for types with unnamed fields. |
Sorry, something went wrong.
Done. |
Sorry, something went wrong.
There was a problem hiding this comment.
Very well.
I have few more comments, mostly test suggestions.
Sorry, something went wrong.
|
LGTM! |
Sorry, something went wrong.
|
Thank you for your contribution @XuehaiPan. |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
Resolves #110222
The implementation in this PR is roughly equivalent to:
Refactored: