aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@python.org>2020-12-26 02:58:33 +0100
committerGitHub <noreply@github.com>2020-12-26 02:58:33 +0100
commitea251806b8dffff11b30d2182af1e589caf88acf (patch)
tree10d413170c8e71dd19079b3d22eea4ebd5ddf7a5 /Include
parentbpo-42694: Prevent creating _curses_panel.panel (GH-23948) (diff)
downloadcpython-ea251806b8dffff11b30d2182af1e589caf88acf.tar.gz
cpython-ea251806b8dffff11b30d2182af1e589caf88acf.tar.bz2
cpython-ea251806b8dffff11b30d2182af1e589caf88acf.zip
bpo-40521: Per-interpreter interned strings (GH-20085)
Make the Unicode dictionary of interned strings compatible with subinterpreters. Remove the INTERN_NAME_STRINGS macro in typeobject.c: names are always now interned (even if EXPERIMENTAL_ISOLATED_SUBINTERPRETERS macro is defined). _PyUnicode_ClearInterned() now uses PyDict_Next() to no longer allocate memory, to ensure that the interned dictionary is cleared.
Diffstat (limited to 'Include')
-rw-r--r--Include/internal/pycore_interp.h11
1 files changed, 11 insertions, 0 deletions
diff --git a/Include/internal/pycore_interp.h b/Include/internal/pycore_interp.h
index 339c2c4c61..58b1126712 100644
--- a/Include/internal/pycore_interp.h
+++ b/Include/internal/pycore_interp.h
@@ -76,6 +76,17 @@ struct _Py_unicode_state {
shared as well. */
PyObject *latin1[256];
struct _Py_unicode_fs_codec fs_codec;
+
+ /* This dictionary holds all interned unicode strings. Note that references
+ to strings in this dictionary are *not* counted in the string's ob_refcnt.
+ When the interned string reaches a refcnt of 0 the string deallocation
+ function will delete the reference from this dictionary.
+
+ Another way to look at this is that to say that the actual reference
+ count of a string is: s->ob_refcnt + (s->state ? 2 : 0)
+ */
+ PyObject *interned;
+
// Unicode identifiers (_Py_Identifier): see _PyUnicode_FromId()
struct _Py_unicode_ids ids;
};