Skip to content

gh-89653: PEP 670: Convert tuple macros to functions#91786

Merged
vstinner merged 1 commit intopython:mainfrom
vstinner:tuple_macros
Apr 21, 2022
Merged

gh-89653: PEP 670: Convert tuple macros to functions#91786
vstinner merged 1 commit intopython:mainfrom
vstinner:tuple_macros

Conversation

@vstinner
Copy link
Copy Markdown
Member

Convert macros to static inline functions:

  • PyTuple_GET_SIZE()
  • PyTuple_SET_ITEM()
  • PyList_GET_SIZE()
  • PyList_SET_ITEM()

Add a macro converting arguments to PyTupleObject*, PyListObject* or
PyObject* to prevent emitting new compiler warnings.

According to PEP 670, PyTuple_GET_ITEM() and PyList_GET_ITEM() are
left as macros.

Convert macros to static inline functions:

* PyTuple_GET_SIZE()
* PyTuple_SET_ITEM()
* PyList_GET_SIZE()
* PyList_SET_ITEM()

Add a macro converting arguments to PyTupleObject*, PyListObject* or
PyObject* to prevent emitting new compiler warnings.

According to PEP 670, PyTuple_GET_ITEM() and PyList_GET_ITEM() are
left as macros.
@vstinner
Copy link
Copy Markdown
Member Author

@erlend-aasland: I chose to also rename "i" to "index" and "v" to "value", and I changed the order to follow the structure member order and the logical order (get, then set).

@vstinner vstinner merged commit 2a5f171 into python:main Apr 21, 2022
@vstinner vstinner deleted the tuple_macros branch April 21, 2022 14:52
@vstinner
Copy link
Copy Markdown
Member Author

Thanks for the reviews.

@erlend-aasland
Copy link
Copy Markdown
Contributor

Looks good!

@vstinner
Copy link
Copy Markdown
Member Author

Thanks for the post-commit review @erlend-aasland, it's worth it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants