Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Next Next commit
unicode doc 1
  • Loading branch information
Yashp002 committed Jan 6, 2026
commit c8d2ceeaa46aaf7e1282de0d23514739da8ad1f2
14 changes: 14 additions & 0 deletions Doc/c-api/unicode.rst
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,20 @@ access to internal read-only data of Unicode objects:
.. versionadded:: 3.3


.. c:macro:: PyUnicode_IS_COMPACT(o)

Return true if the Unicode object *o* is a compact string.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Could you provide a small definition of what a "compact" string is? Same goes for IS_COMPACT_ASCII below.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Sure, coming right up.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Could you also move the docs to the structs they refer to?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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.


.. versionadded:: 3.3


.. c:macro:: PyUnicode_IS_COMPACT_ASCII(o)

Return true if the Unicode object *o* is a compact ASCII string.

.. versionadded:: 3.3


.. c:function:: void PyUnicode_WRITE(int kind, void *data, \
Py_ssize_t index, Py_UCS4 value)

Expand Down
Loading