[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.python

Is it possible to use re2 from Python?

_wolf

3/14/2010 3:58:00 PM


i just discovered http://code.google..., 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-f...
and, even earlier, http://groups.google.com/group/re2-dev/t/59b783...)
7 Answers

Kev

3/14/2010 6:19:00 PM

0

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

3/14/2010 8:50:00 PM

0

2010/3/14 _wolf <wolfgang.lipp@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...
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

3/14/2010 9:40:00 PM

0


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

3/14/2010 9:41:00 PM

0


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

pointers? i searched but didn’t find anything.

Kev

3/15/2010 7:50:00 AM

0

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/0...

_wolf

3/24/2010 5:44:00 PM

0


yes we can! http://github.com/face...

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

now gotta go and try it out.

Tim Wintle

3/25/2010 9:34:00 AM

0

On Wed, 2010-03-24 at 10:44 -0700, _wolf wrote:
> yes we can! http://github.com/face...

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