Is it necessary to compile in the ** re module used in Python regular expressions? Check **.
Something like the following.
pattern2 = re.compile('.ou.')
As many have written, it seems to be ** special, meaningless **. This has no merit such as ** speeding up. ** **
I also expected it to be faster.
But,
pattern2 = re.compile('.ou.')
What do you need to do over time for small inputs like? If you don't have to spend time, you can do it every time.
(Although there are talks about cash etc., there is a feeling of being forced.)
As conclusion, There is no particular meaning. However, the way the code is written will change, so it may be meaningful from that perspective. (See below)
this is, ** The word compile may just be a little too impressive. .. .. For example, if it's something like set_pat (pattern), I don't think anyone noticed it. ** **
There was a question and answer on stackoverflow that could be helpful. https://stackoverflow.com/questions/452104/is-it-worth-using-pythons-re-compile
Title: ** Is it worth using Python's re.compile? **
was.
Nothing in particular. (At first, I tried to measure the processing time, including other things, but it fell here.)
Recommended Posts