bpo-35582: Argument Clinic: inline parsing code for positional parameters. - #11313
Merged
serhiy-storchaka merged 5 commits intoJan 11, 2019
Merged
Conversation
Member
Author
|
Added some examples on the tracker. |
vstinner
reviewed
Jan 11, 2019
| Py_ssize_t, Py_ssize_t); | ||
| #define _PyArg_CheckPositional(funcname, nargs, min, max) \ | ||
| (((min) <= (nargs) && (nargs) <= (max)) \ | ||
| || _PyArg_CheckPositional((funcname), (nargs), (min), (max))) |
Member
There was a problem hiding this comment.
Would it be possible to find a different name for the function? Otherwise, it's unclear what is _PyArg_CheckPositional(). For _PyUnicodeWriter, I used _PyUnicodeWriter_Prepare (macro) and _PyUnicodeWriter_PrepareInternal (func) names.
/* Prepare the buffer to write 'length' characters
with the specified maximum character.
Return 0 on success, raise an exception and return -1 on error. */
#define _PyUnicodeWriter_Prepare(WRITER, LENGTH, MAXCHAR) \
(((MAXCHAR) <= (WRITER)->maxchar \
&& (LENGTH) <= (WRITER)->size - (WRITER)->pos) \
? 0 \
: (((LENGTH) == 0) \
? 0 \
: _PyUnicodeWriter_PrepareInternal((WRITER), (LENGTH), (MAXCHAR))))
/* Don't call this function directly, use the _PyUnicodeWriter_Prepare() macro
instead. */
PyAPI_FUNC(int)
_PyUnicodeWriter_PrepareInternal(_PyUnicodeWriter *writer,
Py_ssize_t length, Py_UCS4 maxchar);
You may write a static inline function rather than a macro.
Member
Author
There was a problem hiding this comment.
It is a common method to use the same name for the function and optimizing macro. See for example _PyArg_NoKeywords.
Member
There was a problem hiding this comment.
Ok. It was just a proposition, not a requirement ;-) I'm also fine with have the same name for the macro and function.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
https://bugs.python.org/issue35582