3 ms·
Isn't sys.intern a cache itself? What does adding another layer of cacheing on top add?
by twic 5y ago
Isn't sys.intern a cache itself? What does adding another layer of cacheing on top add?
- ciupicri 5y agoYou're right, PyUnicode_InternInPlace (which is called by sys.intern) already caches results using a regular Python dictionary, so @functools.cache wouldn't add any value. It happened a long time ago, but I think I misread something about sys.intern not being able to handle lots and lots of strings, so I added an extra layer of caching, but it looks like it's not needed anymore. [1]: https://github.com/python/cpython/blob/3.10/Objects/unicodeobject.c#L15794 https://github.com/python/cpython/blob/3.10/Objects/unicodeo...