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 unicodeobject.h macros to functions #91773

Merged
merged 2 commits into from
Apr 21, 2022
Merged

gh-89653: PEP 670: Convert unicodeobject.h macros to functions #91773

merged 2 commits into from
Apr 21, 2022

Conversation

vstinner
Copy link
Member

Convert unicodeobject.h macros to static inline functions:

  • PyUnicode_MAX_CHAR_VALUE()
  • PyUnicode_READ()
  • PyUnicode_READY()
  • PyUnicode_READ_CHAR()
  • PyUnicode_WRITE()

Move PyUnicode_READY() after _PyUnicode_Ready(), since it uses
_PyUnicode_Ready().

Static inline functions are wrapped by macros which casts arguments
with _PyObject_CAST() and casts 'kind' arguments to "unsigned int" to
prevent introducing new compiler warnings when passing "const
PyObject*".

Convert unicodeobject.h macros to static inline functions:

* PyUnicode_MAX_CHAR_VALUE()
* PyUnicode_READ()
* PyUnicode_READY()
* PyUnicode_READ_CHAR()
* PyUnicode_WRITE()

Move PyUnicode_READY() after _PyUnicode_Ready(), since it uses
_PyUnicode_Ready().

Static inline functions are wrapped by macros which casts arguments
with _PyObject_CAST() and casts 'kind' arguments to "unsigned int" to
prevent introducing new compiler warnings when passing "const
PyObject*".
@vstinner
Copy link
Member Author

cc @erlend-aasland

Copy link
Contributor

@erlend-aasland erlend-aasland left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! Increased readability and maintainability 🎉🥳

⚠️⛏️ nitpick ⛏️ ⚠️
  • I'd remove the last elses in your if-else-ladders
  • I'd use an if-else ladder instead of a switch in PyUnicode_WRITE

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.

3 participants