3 ms·
Not sure if your example is considered to be complete, but AFAIK, static strings with the same content are the same instance. I'm side stepping your question in
by yokaze 5y ago
Not sure if your example is considered to be complete, but AFAIK, static strings with the same content are the same instance. I'm side stepping your question in a way, but you can validate that easily with the "is" keyword.
for k1,k2 in itertools.zip_longest(d1, d2):
print(k1 is k2)
- wheelerof4te 5y agoYou make a good point, but I believe that the behaviour you see is more because of cPython's internal string handling. At least that is what PEP 412 is implying. For example: s1 = "cookie" s2 = "cookie" print(s1 is s2) # should print True