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

Skip to content
Prev Previous commit
Next Next commit
fix 1 unicode
  • Loading branch information
Yashp002 committed Jan 6, 2026
commit 26e9725fb6b6aa6363d143f19e1f47278d0450aa
6 changes: 4 additions & 2 deletions Doc/c-api/unicode.rst
Original file line number Diff line number Diff line change
Expand Up @@ -132,14 +132,16 @@ access to internal read-only data of Unicode objects:
.. 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.


Compact strings use a single memory block for
the structure and the character data.
.. versionadded:: 3.3


.. c:macro:: PyUnicode_IS_COMPACT_ASCII(o)

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

A compact ASCII string uses a single memory block
and contains only ASCII characters.
.. versionadded:: 3.3


Expand Down
Loading