Could frozendict or frozenmap be of some use for PEP 683 (Immortal objects)?

Marco Sulla Marco.Sulla.Python at gmail.com
Thu Mar 10 07:58:27 EST 2022


On Wed, 9 Mar 2022 at 23:28, Martin Di Paola <martinp.dipaola at gmail.com> wrote:
> Think in the immutable strings (str). What would happen with a program
> that does heavy parsing? I imagine that it will generate thousands of
> little strings. If those are immortal, the program will fill its memory
> very quickly as the GC will not reclaim their memory.

Well, as far as I know immortality was also suggested for interned
strings. If I understood well, the problem with "normal" strings is
that they are not really immutable in CPython. They have cache etc.
Also frozendict caches hash, but that cache can be easily removed.


More information about the Python-list mailing list