> > An occasional run through the 'interned' dict (in stringobject.c) > > looking for strings with refcount 2 would do this. Maybe something > > for the gc module do handle as a service whenever it runs its > > last-generation collection? > > This has the potential of breaking applications that remember the id() > of an interned string, instead of its value. Ow, good point! It's also quite possible that there are no outside references to an interned string, but another string with the same value still references the interned string from its ob_sinterned field. E.g. s = "frobnicate"*3 t = intern(s) del t To solve this, we would have to make the ob_sinterned slot count as a reference to the interned string. But then string_dealloc would be complicated (it would have to call Py_XDECREF(op->ob_sinterned)), possibly slowing things down. Is this worth it? The fear for unbounded growth of the interned strings table is pretty common amongst authors of serious long-running programs. --Guido van Rossum (home page: http://www.python.org/~guido/)
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4