-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Use string internment for constant strings #1412
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
In general I think this is a good idea. Both for performance reasons as well as for CPython compliance. Is there any limit to the amount of strings which are interned? |
I don't think so. I have not looked deeply at the CPython implementation yet, but it seems like the vast majority of compile-time constants (apart from some exceptions) are interned. I'm not sure if any strings are interned at runtime. https://rushter.com/blog/python-strings-and-memory/
|
Strings passed to |
@coolreader18 implemented it |
CPython and many other VMs do this, as it can save memory. Mostly it is a feature, but it results in slightly different behavior of the
is
keyword between RustPython and CPython. Theoretically if someone were relying on that behavior (not terribly common I would imagine, but I'm sure some people do) then their would not work the same on RustPython.https://medium.com/@bdov_/https-medium-com-bdov-python-objects-part-iii-string-interning-625d3c7319de
The text was updated successfully, but these errors were encountered: