[Python-ideas] Checking interned string after stringobjects concat?

Yinbin Ma mayinbing12 at gmail.com
Sat Apr 21 06:25:38 EDT 2018


Hi all:

I notice that if concatenating two stringobjects, PVM will not check the
dictionary of interned string. For example:

>>> a = "qwerty"
>>> b = "qwe"
>>> c = "rty"
>>> d = b+c
>>> id(a)
4572089736
>>> id(d)
4572111176
>>> e = "".join(["qwe","rty"])
>>> id(e)
4546460280

But if concatenating two string directly, PVM would check the dictionary:

>>> a = "qwerty"
>>> b = "qwe"+"rty"
>>> id(a)
4546460112
>>> id(b)
4546460112

It happens in Py2 and Py3 both.
Is it necessary for fixing this bug or not?


Cheers!
---
Yinbin
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20180421/a172b3f8/attachment.html>


More information about the Python-ideas mailing list