[Python-ideas] Keyword/Symbol literals
storchaka at gmail.com
Thu Jan 22 07:35:41 CET 2015
On 22.01.15 00:30, Chris Angelico wrote:
> On Thu, Jan 22, 2015 at 9:24 AM, Greg Ewing <greg.ewing at canterbury.ac.nz> wrote:
>> I believe there is a flag in the string object indicating
>> that it is interned, so the interpreter *does* know this.
>> It's just not visible to Python code.
> Huh. Okay. It's not made use of for optimizing the == operator, which
> ought to be easy to do. Or is the cost of checking not worth it?
The cost of checking is not worth it. Comparing hashes (which are
already calculated for interned strings) before comparing contents has
almost the same effect and this proposition was tested and rejected.
This makes double work in dict lookup which is more common case.
More information about the Python-ideas