[Python-ideas] string codes & substring equality
Mark Lawrence
breamoreboy at yahoo.co.uk
Wed Nov 27 16:43:54 CET 2013
On 27/11/2013 15:26, Masklinn wrote:
> On 2013-11-27, at 15:32 , spir <denis.spir at gmail.com> wrote:
>> Coming back to python after a long time.
>> My present project is about (yet another) top-down matching / parsing lib. There are 2 issues that, I guess, may be rather easily solved by simple string methods. The core point is that any scanning / parsing process ends up, a the lowest level, constantly comparing either single-char (rather single-code) substrings or constant (literal) substrings of the source string. This is the only operation which, when successful, actually advances in the source. Thus, it is certainly worth having it efficient, or at the minimum not having it needlessly inefficient. I suppose the same functionalities can be highly useful in various other use cases of text processing.
>> Note again that I'm rediscovering Python (with some pleasure :-), thus may miss known solutions -- but I asked on the tutor mailing list.
>>
>> In both cases, I guess ordinary idiomatic Python code actually _creates_ a new string object, as a substring of length 1 or more, which is otherwise useless
>
> Have you tried using memoryviews? (or buffers for older python compat’)
>
Python 3.3.3 on Windows 7 TypeError: memoryview: str object does not
have the buffer interface.
--
Python is the second best programming language in the world.
But the best has yet to be invented. Christian Tismer
Mark Lawrence
More information about the Python-ideas
mailing list