[Python-Dev] Re: Automatic flex interface for Python?

Tim Peters tim.one@comcast.net
Fri, 23 Aug 2002 12:53:02 -0400

[attribution lost]
>>> It's an implementation problem.  You find yourself doing a lot of
>>> string accessing and pasting, creating several new objects per
>>> input char.

[Greg Ewing]
>> Not necessarily! Plex manages to do it without any
>> of that.
>> The trick is to leave all the characters in the input
>> buffer and just *count* how many characters make up
>> the next token.

> you can do that without even looking at the characters?

1-character strings are shared; string[i] doesn't create a new object except
for the first time that character is seen.  string_item() in particular uses
the character found to index into an array of 1-character string objects.