Lazy string with re.match?

Greg Ewing (using news.cis.dfn.de) ckea25d02 at sneakemail.com
Tue Apr 8 00:47:51 EDT 2003


Magnus Lie Hetland wrote:
> I first tried
> simply implementing __getitem__, but was told in no uncertain terms
> that a string or buffer was expected by the re object.

What it's really telling you is that it needs all the chars
available all at once in one block of memory (that's what
a "buffer" provides). So, unfortunately, what you want is
impossible to do with the re module.

> Any ideas?

Yes - use Plex instead:

   http://www.cosc.canterbury.ac.nz/~greg/python/Plex/

Plex reads its data sequentially from a stream, just as
you want. The only downside is that it's currently not as
fast as re, being implemented in pure Python. But, even
as we speak, I'm applying Pyrex to this problem, and very
soon I hope to release a much faster version...

-- 
Greg Ewing, Computer Science Dept,
University of Canterbury,	
Christchurch, New Zealand
http://www.cosc.canterbury.ac.nz/~greg





More information about the Python-list mailing list