Skip to content
Advertisement

how to make this javascript for-loop converted to python code with same or faster execution time?

Please help to optimize my python code, I wrote this JS code and tried to convert it to python that I need the execution time comparable to the original code.

The original code follows for-loop in JS, I transferred the code literally by using pure python and numpy but I didn’t optimize it well resulting in poor execution time and memory usage.

This code calculates a preset enemy vs player power with +-10% difference and do a random roll then get the player winrate. The target is to set the HERO_POWER or ENEMY_POWER atleast in 100000-300000 range.

JavaScript

Advertisement

Answer

upon searching the web, I tried to translate the python function code using ‘numba’ and it shows faster execution with no additional thing to do on my end in this context.

JavaScript
User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement