Conversation
|
I wouldn't expect these changes to be merged given the authors intent with these benchmarks is to compare "the same" implementation of the algorithm. If Python struggles with for-loops, the benchmark is supposed to show that. I should note that the C implementation of this benchmark, and every other language, is also limited by the way the algorithm is implemented. It's purposely inefficient. If allowed to make equivalent optimizations to yours on the C benchmark, it would be another 40 times faster. So, this would make Python much faster. Applied to every other language, they would all end up much faster too. |
|
Thanks for submitting, however this significantly alters the amount of "work" the program is doing. We need to do ~ the same ~ amount of work in all programs for this to be reasonably fair. |
Changes Made:
Elimination of Nested Loops:
Replaced the "for" loops with vectorized operations using NumPy, which are significantly faster.
Use of NumPy for Mathematical Operations:
The modulus and summation operations were performed on a vector using NumPy ("np.arange" and ".sum()").
Efficient Array Creation:
Used "np.full" to create the array initialized with the previously calculated sum value.
Vectorized Randomization and Summation:
Added the random value "r" directly to the array "a" using vectorized operations.