Do you need a Python re.compile?

Purpose

Is it necessary to compile in the ** re module used in Python regular expressions? Check **.

Something like the following.

pattern2 = re.compile('.ou.')

result

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

reference

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.

Summary

Nothing in particular. (At first, I tried to measure the processing time, including other things, but it fell here.)

Recommended Posts

Do you need a Python re.compile?
Why do you add a main ()-if statement in Python?
Python | What you can do with Python
What to do if you get a minus zero in Python
Do a non-recursive Euler Tour in Python
Do you make something like a rocket?
Python --How do you split a list into evenly sized chunks in Python?
What happens if you do "import A, B as C" in Python?
[Python, Scala] Do a tutorial for Apache Spark
You can easily create a GUI with Python
Implement "All You Need Is Kill" in Python
A * algorithm (Python edition)
Consideration when you can do a good job in 10 years with Python3 and Scala3.
[Python] Take a screenshot
Create a Python module
A python lambda expression ...
python: 3.8-Handling Exception: you need a C compiler to build uWSGI error with alpine
Daemonize a Python process
% And str.format () in Python. Which one do you use?
BigQuery-If you get a Reason: responseTooLarge error in Python
If you encounter a "Unicode Decode Error" in Python
Until you insert data into a spreadsheet in Python
Do Houdini with Python3! !! !!
I made a python library to do rolling rank
Create a Python environment
Python3> round (a --b, 7)
[Python] How do you use lambda expressions? ?? [Scribbles] [Continued-1]
Python Minor Environment Retsuden-How many Python environments do you know? ~
How much do you know the basics of Python?
What to do when you can't bind CaboCha to Python
Do you have any recommendations for a commentary book on Google App Engine / Python development?
[Django] A memorandum when you want to communicate asynchronously [Python3]
[Python version] Why can't you do object-oriented development in Java?
Knowledge you need to know when programming competitive programming with Python2
If you write TinderBot in Python, she can do it
How to import a file anywhere you like in Python
What you can do with the Python standard library statistics
Do something like a Python interpreter in Visual Studio Code
A set of script files that do wordcloud in Python3
When you want to hit a UNIX command on Python
[Python] What do you do with visualization of 4 or more variables?
Call CPLEX from Python (DO cplex)
AtCoder ABC 177 Python (A ~ E)
Take a screenshot in Python
Do Django with CodeStar (Python3.6.8, Django2.2.9)
Create a Wox plugin (Python)
Create a function in Python
AtCoder ABC 178 Python (A ~ E)
A road to intermediate Python
AtCoder ABC 176 Python (A ~ E)
Python list is not a list
A memorandum about correlation [Python]
Make a bookmarklet in Python
Building a Python virtual environment
Create a python numpy array
Make a fortune with Python
I made a python text
A memorandum about Python mock
AtCoder ABC 182 Python (A ~ D)
Build a Python environment offline
Draw a heart in Python