Is it possible to use re2 from Python?

W

_wolf

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)
 
K

Kev Dwyer

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
 
V

Vlastimil Brom

2010/3/14 _wolf said:
...
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
 
W

_wolf

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.
 
T

Tim Wintle


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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top