8000 gh-128137: Update PyASCIIObject to handle interned field with the atomic operation by corona10 · Pull Request #128196 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

gh-128137: Update PyASCIIObject to handle interned field with the atomic operation #128196

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

Merged
merged 19 commits into from
Jan 5, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Address code review
  • Loading branch information
corona10 committed Jan 1, 2025
commit 53147e76fc21a54f58e3fc842b6c1c7eb4a85cba
16 changes: 10 additions & 6 deletions Include/cpython/unicodeobject.h
Original file line number Diff line number Diff line change
Expand Up 8000 @@ -132,21 +132,25 @@ typedef struct {
* all characters are in the range U+0000-U+10FFFF
* at least one character is in the range U+10000-U+10FFFF
*/
unsigned int kind:3;
unsigned char kind:3;
/* Compact is with respect to the allocation scheme. Compact unicode
objects only require one memory block while non-compact objects use
one block for the PyUnicodeObject struct and another for its data
buffer. */
unsigned int compact:1;
unsigned char compact:1;
/* The string only contains characters in the range U+0000-U+007F (ASCII)
and the kind is PyUnicode_1BYTE_KIND. If ascii is set and compact is
set, use the PyASCIIObject structure. */
unsigned int ascii:1;
unsigned char ascii:1;
/* The object is statically allocated. */
unsigned int statically_allocated:1;
unsigned char statically_allocated:1;
/* Padding to ensure that PyUnicode_DATA() is always aligned to
4 bytes (see issue #19537 on m68k). */
unsigned int :18;
4 bytes (see issue #19537 on m68k) and we use unsigned char to avoid
the extra four bytes on 32-bit Windows. This is restricted features
for specific compilers including GCC, MSVC, Clang and IBM's XL compiler. */
unsigned char :2;
unsigned char :8;
unsigned char :8;
} state;
} PyASCIIObject;

Expand Down
2 changes: 0 additions & 2 deletions Lib/test/test_str.py
Original file line number Diff line number Diff line change
Expand Up @@ -2450,8 +2450,6 @@ def test_expandtabs_optimization(self):

def test_raiseMemError(self):
asciifields = "nnb"
if not support.is_wasi:
asciifields = asciifields + "7x"
compactfields = asciifields + "nP"
ascii_struct_size = support.calcobjsize(asciifields)
compact_struct_size = support.calcobjsize(compactfields)
Expand Down
2 changes: 0 additions & 2 deletions Lib/test/test_sys.py
Original file line number Diff line number Diff line change
Expand Up @@ -1763,8 +1763,6 @@ class newstyleclass(object): pass
'\U00010000'*30, '\U0010ffff'*100]
# also update field definitions in test_unicode.test_raiseMemError
asciifields = "nnb"
if not support.is_wasi:
asciifields = asciifields + "7x"
compactfields = asciifields + "nP"
unicodefields = compactfields + "P"
for s in samples:
Expand Down
Loading
0