Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 34k
gh-112068: C API: Add support of nullable arguments in PyArg_Parse (suffix)#121303
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
gh-112068: C API: Add support of nullable arguments in PyArg_Parse (suffix) #121303
Uh oh!
There was an error while loading. Please reload this page.
Conversation
serhiy-storchaka commented Jul 3, 2024 • edited
Loading Uh oh!
There was an error while loading. Please reload this page.
edited
Uh oh!
There was an error while loading. Please reload this page.
picnixz left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm really sorry that you needed to implement the suffix just for me to actually understand that it's probably harder to maintain and to extend compared to the prefix case.
The only reason why I would advocate for the suffix is more because of its use in other languages but maybe I shouldn't have kept that argument at the top of my list and should have rather go for a more simple implementation (for instance in TypeScript, you write function sumTwoMaybeThree(x: number, y: number, z?: number): number and in other languages as I said you have the ?. operator.
In addition, since (...)? is not yet implemented, I assume that it would be even more complex since you need to open / close contexts and after all that, you still need to parse that ?. However ?(...) would be easier to implement I think since you could add the flag beforehand and process (...) normally.
By the way, is there a reason why we have a huge switch instead of some separate functions like in _testcapi/getargs.c? is it only for efficiency purposes and to reduce function calls (though those could be probably inlined)?
Uh oh!
There was an error while loading. Please reload this page.
serhiy-storchaka commented Jul 3, 2024
In case of multicharacter format unit you need to reorganize the code and add new code at all right places. This is actually simpler than I thought, because the same macros can be used in all cases (except For |
serhiy-storchaka commented Jul 4, 2024
I managed to implement |
serhiy-storchaka commented Jan 8, 2025
Added the documentation. It is now ready for review. |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Misc/NEWS.d/next/C_API/2025-01-08-18-55-57.gh-issue-112068.ofI5Fl.rst Outdated Show resolvedHide resolved
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Co-authored-by: Bénédikt Tran <[email protected]>
f5f1ac8 into python:mainUh oh!
There was an error while loading. Please reload this page.
…PyArg_Parse (pythonGH-121303)" This reverts commit f5f1ac8.
…PyArg_Parse (pythonGH-121303)" This reverts commit f5f1ac8.
…PyArg_Parse (pythonGH-121303)" This reverts commit f5f1ac8.
…nts in PyArg_Parse (pythonGH-121303)" (pythonGH-136991) (cherry picked from commit 3a89dfe) Co-authored-by: Serhiy Storchaka <[email protected]>
This is a variant of #121187, but with suffix instead of prefix.
i?instead of?i.