Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Is it possible to use re2 from Python?

133 views
Skip to first unread message

_wolf

unread,
Mar 14, 2010, 11:57:36 AM3/14/10
to

i just discovered http://code.google.com/p/re2, a promising library
that uses a long-neglected way (Thompson NFA) to implement a regular
expression engine that can be orders of magnitudes faster than the
available engines of awk, Perl, or Python.

so i downloaded the code and did the usual sudo make install thing.
however, that action had seemingly done little more than adding /usr/
local/include/re2/re2.h to my system. there seemed to be some `*.a
file in addition, but then what is it with this *.a extension?

i would like to use re2 from Python (preferrably Python 3.1) and was
excited to see files like make_unicode_groups.py in the distro (maybe
just used during the build process?). those however were not deployed
on my machine.

how can i use re2 from Python?

(this message appeared before under
http://stackoverflow.com/questions/2439345/is-it-possible-to-use-re2-from-python
and, even earlier, http://groups.google.com/group/re2-dev/t/59b78327ec3cca0a)

Kev Dwyer

unread,
Mar 14, 2010, 2:18:45 PM3/14/10
to pytho...@python.org
On Sun, 14 Mar 2010 08:57:36 -0700, _wolf wrote:


>
> how can i use re2 from Python?
>

Hello Wolf,

There's a recent thread about this on the python-dev list,
Unfortunately it seems to suggest that there are no Python
bindings at present.

Cheers,

Kev

Vlastimil Brom

unread,
Mar 14, 2010, 4:49:56 PM3/14/10
to pytho...@python.org
2010/3/14 _wolf <wolfga...@gmail.com>:
>...

> i would like to use re2 from Python (preferrably Python 3.1) and was
> excited to see files like make_unicode_groups.py in the distro (maybe
> just used during the build process?). those however were not deployed
> on my machine.
>...
>

If you would need a re engine with features like unicode rangees,
script, and character properties classes and many others, you may try
the proposed implementation of the re library currently available in
python issue tracker:
http://bugs.python.org/issue2636
I am personally more than satisfied with this development version
sofar, however, as some new feature like unlimited lookarounds etc.
suggest, it is a classic backtracking engine (as opposed to re2, if
you need this very implementation).

hth
vbr

_wolf

unread,
Mar 14, 2010, 5:40:07 PM3/14/10
to

i am afraid that thread goes straight perpendicular to what re2 is
supposed to be, or do. my suggestion for these folks would be to
create a new, clean interface to stop the violence that comes with the
Python ``re`` interface, and open the thing up so one can plug in
``re`` implementations as are needed. when i absolutely need a
feature, i can always go to the slower machine; simpler regular
expressions could be dealt with more efficiently.

_wolf

unread,
Mar 14, 2010, 5:40:34 PM3/14/10
to

> There's a recent thread about this on the python-dev list,

pointers? i searched but didn’t find anything.

Kev Dwyer

unread,
Mar 15, 2010, 3:50:09 AM3/15/10
to pytho...@python.org
On Sun, 14 Mar 2010 14:40:34 -0700, _wolf wrote:

>> There's a recent thread about this on the python-dev list,
>
> pointers? i searched but didn’t find anything.

http://mail.python.org/pipermail/python-dev/2010-March/098354.html

_wolf

unread,
Mar 24, 2010, 1:44:13 PM3/24/10
to

yes we can! http://github.com/facebook/pyre2

as pointed out by http://stackoverflow.com/users/219162/daniel-stutzbach

now gotta go and try it out.

Tim Wintle

unread,
Mar 25, 2010, 5:34:17 AM3/25/10
to _wolf, pytho...@python.org
On Wed, 2010-03-24 at 10:44 -0700, _wolf wrote:
> yes we can! http://github.com/facebook/pyre2

I had made a thin wrapper experiment with here - looks like the version
he's shipped is relatively complete and compatible with the re module
though.

I'll be interested in seeing how well it performs - The wrapper I had
been experimenting with ended up far slower than the re module for
simple expressions - and the fastest codepaths in RE2 seem to be ones
that are incompatible with the API we're used to using in the re module.

Tim

0 new messages