PlummersSoftwareLLC / Primes

Prime Number Projects in C#/C++/Python
https://plummerssoftwarellc.github.io/PrimeView/
2.44k stars 575 forks source link

Optimization of python solution_3 (using numpy) #903

Closed Volbla closed 1 year ago

Volbla commented 1 year ago

Description

Making the sieve faster by working closer with numpy's datatype, and by performing fewer calculations in plain python. I measure a 15% - 20% speed increase.

Renamed two local variables for clarity (v -> bit; step -> prime).

Contributing requirements

rbergen commented 1 year ago

@Volbla Thank you for your submission.

@emillynge I'm interested in your feedback on this proposed change to your solution, if you'd like to provide any?

rbergen commented 1 year ago

I can confirm a speed increase, but on my system it's close to 10%. That's still an improvement, so I'll merge this after CI completes successfully.