[Python-ideas] string codes & substring equality

Greg Ewing greg.ewing at canterbury.ac.nz
Fri Nov 29 07:56:03 CET 2013


spir wrote:
> I thought you (Greg) meant users (like me) who parse or scan strings 
> piecemeal could build a list of 1-char strings before starting:

No, I meant that there would be a built-in cache operating
behind the scenes, so that whenever you index a string and
the resulting character has been extracted from a string
before, you'd get the cached object instead of a new one.

The advantage would be that no new functions or methods
are needed.

> But isn't it easier (and cheaper and more "intuitive") just to have a 
> method like s.code(i)?

It would help with code that use single-char strings for
more purposes than just taking the ord() of them.

-- 
Greg


More information about the Python-ideas mailing list