Uh oh!
There was an error while loading. Please reload this page.
gh-141004: Document PyUnicode_IS_COMPACT and PyUnicode_IS_COMPACT_ASCII macros - #143494
Conversation
| .. c:macro:: PyUnicode_IS_COMPACT(o) | ||
| Return true if the Unicode object *o* is a compact string. |
There was a problem hiding this comment.
Could you provide a small definition of what a "compact" string is? Same goes for IS_COMPACT_ASCII below.
There was a problem hiding this comment.
I'd rather say they use the PyCompactUnicodeObject struct (and PyASCIIObject for COMPACT_ASCII). The docs for the structs discourage using them directly, which is a good thing. I don't think we should provide any details on the storage layouts.
Ideally, document these together with the struct.
There was a problem hiding this comment.
Could you also move the docs to the structs they refer to?
There was a problem hiding this comment.
Could you also move the docs to the structs they refer to?
I've moved them, please verify if its satisfactory placement. it groups the "Type" and "How to check for that Type" logic imo.
(FWIW, I want to deprecate these, but they have a use case that'll need a PEP with better API: https://discuss.python.org/t/82543.) [edit: link fixed) |
encukou
commented
Jan 7, 2026
Could you also remove these from |
Yashp002
commented
Jan 7, 2026
I'll update the wording. And yes, I'll remove them from ignored_c_api.txt to ensure they are properly checked going forward. |
Uh oh!
There was an error while loading. Please reload this page.
| @@ -89,5 +89,4 @@ PyUnstable_EXECUTABLE_KIND_SKIP | |||
| # cpython/pylifecycle.h | |||
| Py_FrozenMain | |||
| # cpython/unicodeobject.h | |||
There was a problem hiding this comment.
Please remove this comment as well.
Co-authored-by: Petr Viktorin <encukou@gmail.com>
Yashp002
commented
Jan 8, 2026
Test failure unrelated to my docs change - multiprocessing timeout issue. |
|
Yashp002
commented
Jan 9, 2026
Wait I'm sorry, do we go with the incoming change or the current change here? |
ZeroIntensity
commented
Jan 9, 2026
We needed to merge the two. I fixed it for you. |
@ZeroIntensity Yeah my bad, i was a little confused there. Thanks for the help Edit: I also think we need to remove some more lines from the ignore_c_api.txt as it claims some things to be documented but still existing in the file. |
Yashp002
commented
Jan 11, 2026
@ZeroIntensity Could you update me on this PR? |
ZeroIntensity
commented
Jan 11, 2026
It's complaining that some C APIs are documented but also listed in |
Yashp002
commented
Jan 12, 2026
@ZeroIntensity I think i fixed the test problem yeah |
Sorry, @Yashp002 and @encukou, I could not cleanly backport this to |
Sorry, @Yashp002 and @encukou, I could not cleanly backport this to |
…CT_ASCII macros (pythonGH-143494) (cherry picked from commit 42f7c2d)
GH-143785 is a backport of this pull request to the 3.14 branch. |
This PR documents
PyUnicode_IS_COMPACTandPyUnicode_IS_COMPACT_ASCII, which were identified as undocumented public macros in issue #141004.📚 Documentation preview 📚: https://cpython-previews--143494.org.readthedocs.build/