Skip to content
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-89653: PEP 670: Convert tuple macros to functions #91786

Merged
merged 1 commit into from Apr 21, 2022

Conversation

vstinner
Copy link
Member

@vstinner vstinner commented Apr 21, 2022

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
Member Author

vstinner commented Apr 21, 2022

@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
12 checks passed
@vstinner vstinner deleted the tuple_macros branch Apr 21, 2022
@vstinner
Copy link
Member Author

vstinner commented Apr 21, 2022

Thanks for the reviews.

@erlend-aasland
Copy link
Contributor

erlend-aasland commented Apr 22, 2022

Looks good!

@vstinner
Copy link
Member Author

vstinner commented Apr 22, 2022

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.

None yet

5 participants