How to increase python processor usage

I am a beginner programmer, so a little lost here.

I wrote a small python function that takes a long time to execute depending on the scope of the search that is expected.

After a certain threshold, about a million entries, my program always seems lost. The Python package is not responding, but CPU usage remains constant by about 13%. Also I can not stop the execution of KeyboardInterrupt

So my question is: is it possible to increase CPU usage for my python program to make it work faster?

Side question: Any help on why the python shell stops responding? I do not use excessive memory, I just need to go through a large set as quickly as possible.

+3
source share
1 answer

Is your processor a multi-core processor? If so, there are several ways to use multiple cores with Python.

Built-in is a multiprocessor module. The multiprocessing.Pool class provides vectorization for multiple processors using map () and related methods. There is a compromise here. If you have to transfer large amounts of data between processes, these costs can negate the advantage of multiple cores. Use the appropriate NumPy build. If numpy is built using the multi-threaded ATLAS library, it will be faster with big problems. Use extension modules such as NumberxPr , parallel Python , CorePy, or Copenhagen Vector Byte Code.

, . ("GIL") - Python. , numpy, .

+3

All Articles