How to make a foreign function run as fast as possible in Windows?

jfong at ms4.hinet.net jfong at ms4.hinet.net
Fri Sep 30 21:27:32 EDT 2016


Paul  Moore at 2016/9/30 7:07:35PM wrote:
> OK. So if your Python code only calls the function once, the problem needs to be fixed in the external code (the assembly routine). But if you can split up the task at the Python level to make multiple calls to the function, each to do a part of the task, then you could set up multiple threads in your Python code, each of which handles part of the task, then Python merges the results of the sub-parts to give you the final answer. Does that make sense to you? Without any explicit code, it's hard to be sure I'm explaining myself clearly.
> 

That's what I will do later, to split the task into multiple cores by passing a range parameter (such as 0~14, 15~29, ..) to each instance. Right now, I just embedded the range in the function to make it simple on testing.

At this moment my interest is how to make it runs at 100% core usage. Windows task manager shows this function takes only ~70% usage, and the number varies during its execution, sometimes even drop to 50%.

I also had test a batch file (copied from another discussion forum):
@echo off
:loop
goto loop
It takes ~85% usage, and the number is stable.

The result is obviously different. My question is how to control it:-)

--Jach




More information about the Python-list mailing list