[Python-ideas] string codes & substring equality
spir
denis.spir at gmail.com
Fri Nov 29 07:10:11 CET 2013
On 11/29/2013 12:29 AM, Greg Ewing wrote:
> Chris Angelico wrote:
>> Would you really keep a cache of 1114112 string objects around?
>
> Well, not *exactly* like the int cache... the idea
> would be to remember ones that had been used, not
> pre-generate all possible 1-char strings.
I thought you (Greg) meant users (like me) who parse or scan strings piecemeal
could build a list of 1-char strings before starting:
source_chars = [ch for ch in source]
Then index as needed during parsing.
or maybe keep a list of codes directly
source_ucodes = [ord(ch) for ch in source]
But isn't it easier (and cheaper and more "intuitive") just to have a method
like s.code(i)? Is there some resistance against this proposal? If yes, what
rationale?
Denis
More information about the Python-ideas
mailing list