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

Skip to content

Commit a903ad9

Browse files
committed
_Py_ReleaseInternedStrings(): Private API function to decref and
release the interned string dictionary. This is useful for memory use debugging because it eliminates a huge source of noise from the reports. Only defined when INTERN_STRINGS is defined.
1 parent 8d7f086 commit a903ad9

2 files changed

Lines changed: 12 additions & 0 deletions

File tree

Include/stringobject.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,11 @@ extern DL_IMPORT(PyObject *) _PyString_FormatLong(PyObject*, int, int,
6565
#ifdef INTERN_STRINGS
6666
extern DL_IMPORT(void) PyString_InternInPlace(PyObject **);
6767
extern DL_IMPORT(PyObject *) PyString_InternFromString(const char *);
68+
extern DL_IMPORT(void) _Py_ReleaseInternedStrings(void);
6869
#else
6970
#define PyString_InternInPlace(p)
7071
#define PyString_InternFromString(cp) PyString_FromString(cp)
72+
#define _Py_ReleaseInternedStrings()
7173
#endif
7274

7375
/* Macro, trading safety for speed */

Objects/stringobject.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3217,3 +3217,13 @@ PyString_Fini(void)
32173217
}
32183218
#endif
32193219
}
3220+
3221+
#ifdef INTERN_STRINGS
3222+
void _Py_ReleaseInternedStrings(void)
3223+
{
3224+
if (interned) {
3225+
Py_DECREF(interned);
3226+
interned = NULL;
3227+
}
3228+
}
3229+
#endif /* INTERN_STRINGS */

0 commit comments

Comments
 (0)