[Python-Dev] Re: Alternative implementation of string interning
Ka-Ping Yee
ping@zesty.ca
Wed, 3 Jul 2002 02:33:24 -0700 (PDT)
On Wed, 3 Jul 2002, Oren Tirosh wrote:
> On Tue, Jul 02, 2002 at 11:07:14PM -0700, Ka-Ping Yee wrote:
> > Oren Tirosh wrote:
> > > No two istr instances are equal unless they are
> > > identical. I guess PyString_CheckExact would need to be changed to
> > > accept either String or InternedString.
[...]
> > Pass an 'istr' into a routine that expects strings, and it would
> > appear to be a string right up until someone tried to == it, whereupon
> > all hell would break loose.
>
> I don't understand your assumptions.
I just went on what you wrote: "No two istr instances are equal unless
they are identical." I read that to mean that == would be implemented
with pointer comparison, which would break contracts the way i described.
I see now that is not what you meant.
It appears that what you are proposing is what interned string
comparison already does (since == checks for pointer equality first).
So, the only observable effect of the change would be to break all
code that tests for type(s) == str.
-- ?!ng