Skip to content
Open
Changes from 1 commit
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
4c9f1aa
this reuses SOME interned strings, but not `utf-8` and friends
albertedwardson Oct 27, 2025
d287cc6
Update codeobject.c: - unnecessary check
albertedwardson Oct 27, 2025
d9eaaf6
correct error handling, refcount interned_dict
albertedwardson Oct 28, 2025
5a8b4ce
get interned strings from another dict with interned strings?
albertedwardson Dec 19, 2025
7ab67c4
[SKIP CI] cancelling previous workflow
albertedwardson Dec 19, 2025
4a9e55e
deadlock
albertedwardson Dec 19, 2025
bc861a6
fix usage of Py_BEGIN_CRITICAL_SECTION
albertedwardson Dec 19, 2025
45129f8
just guessing
albertedwardson Dec 19, 2025
485414c
ft build interns and immortilizes everything anyway
albertedwardson Dec 20, 2025
cc63fa2
initial tests
albertedwardson Dec 20, 2025
ad6af24
fix tests
albertedwardson Dec 21, 2025
903cc96
fix tests
albertedwardson Dec 21, 2025
9ec2e09
global cache first
albertedwardson Dec 21, 2025
a1655f1
reorginize tests
albertedwardson Dec 22, 2025
8863b2e
unnecessary, but pretty
albertedwardson Dec 22, 2025
1df49ee
move dicts of interned strings to appropriate section in header
albertedwardson Dec 22, 2025
98ac326
add notes in comments that this is copypaste
albertedwardson Dec 22, 2025
0c6d450
move import
albertedwardson Dec 22, 2025
26fe5d5
move dicts of interned strings to appropriate section in header
albertedwardson Dec 22, 2025
f10e201
reuse `get_interned_dict` from header, and do not refcount it
albertedwardson Dec 22, 2025
9cec5f2
add test, confuse myself even more
albertedwardson Dec 22, 2025
4d9f068
why
albertedwardson Dec 22, 2025
7e07279
:)
albertedwardson Dec 22, 2025
056e2c5
rerun workflow
albertedwardson Dec 23, 2025
9cf07fa
post code review edits
albertedwardson Jan 12, 2026
026917f
Merge branch 'main' into string-interning
albertedwardson Jan 12, 2026
b5b2786
post code review edits
albertedwardson Jan 12, 2026
8be0645
📜🤖 Added by blurb_it.
blurb-it[bot] Jan 12, 2026
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
add test, confuse myself even more
  • Loading branch information
albertedwardson committed Dec 22, 2025
commit 9cec5f2720a81ddd03ccebaeff60f41c49c433d3
27 changes: 20 additions & 7 deletions Lib/test/test_code.py
Original file line number Diff line number Diff line change
Expand Up @@ -1259,19 +1259,32 @@ def test__Py_DECLARE_STR_is_interned(self):
with self.subTest(global_string=global_string):
self.assertIsInterned(eval(f"'{global_string}'"))

noninternable_by_default = textwrap.dedent('''
not-internable
not.internable
не_интернируемый
str with spaces
''' + '\U00100000')

@cpython_only
@unittest.skipIf(Py_GIL_DISABLED, "free-threaded build interns all string constants")
def test_non_internable_strings_not_interned(self):
noninternable_strings = (
"not-internable",
"not.internable",
"не_интернируемый",
"􀀀",
)
for noninternable in noninternable_strings:
for noninternable in self.noninternable_by_default.strip().splitlines():
with self.subTest(noninternable=noninternable):
self.assertIsNotInterned(eval(f"'{noninternable}'"))

@cpython_only
@unittest.skipIf(Py_GIL_DISABLED, "free-threaded build interns all string constants")
def test_explicitly_interned_strings(self):
for noninternable in self.noninternable_by_default.strip().splitlines():
self.assertIsNotInterned(noninternable)
sys.intern(noninternable)
with self.subTest(noninternable=noninternable):
self.assertIsInterned(noninternable)
interned_from_code = eval(f"'{noninternable}'")
self.assertIsInterned(interned_from_code)
self.assertIs(noninternable, interned_from_code)

class CodeWeakRefTest(unittest.TestCase):

def test_basic(self):
Expand Down
Loading