[Python-Dev] sre.c and sre_match()

Tim Peters tim_one@email.msn.com
Tue, 15 Apr 2003 23:22:42 -0400

[Jack Diederich]
> I can't find sre_match() anywhere in the source

It's in _sre.c, here:

SRE_MATCH(SRE_STATE* state, SRE_CODE* pattern, int level)

SRE_MATCH is a macro, and expands to either sre_match or sre_umatch,
depending on whether Unicode support is enabled.  Note that _sre.c arranges
to compile itself *twice*, via its

#include "_sre.c"

This is to get both 8-bit and Unicode versions of the basic routines when
Unicode support is enabled.

> and it doesn't have a man page.

Heh.  Does *any* Python source code have a man page <wink>?

> ...
> I was actually poking around to see how hard it would be to allow
> pure-python string classes to work with the re modules.

Sorry, no idea.  Note that sre works on any object supporting the ill-fated
buffer interface.  You may have a hard time figuring out that too.  But,
e.g., it implies that re can search directly over an mmap'ed file (you don't
need to read the file into a string first).