PlummersSoftwareLLC / Primes

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

Use array slicing to provide ~30-35x improvement with pure python #929

Closed koog1000 closed 1 year ago

koog1000 commented 1 year ago

Description

Use python array slicing to improve performance. No additional libraries, follows same structure as solution 1. Syntactically it is more difficult to read, but functionally does exactly the same thing.

rbergen commented 1 year ago

@davepl I can confirm an increase from 22 iterations per 5 seconds to 483 iterations per 5 seconds on my machine, so approximately 22-fold. Do you have any objections to merging this change to your Python solution?

davepl commented 1 year ago

I’ll defer to the Master of Primes on this one, Rutger!

On Jun 22, 2023, at 7:33 AM, Rutger van Bergen @.***> wrote:

@davepl https://github.com/davepl I can confirm an increase from 22 iterations per 5 seconds to 483 iterations per 5 seconds on my machine, so approximately 22-fold. Do you have any objections to merging this change to your Python solution?

— Reply to this email directly, view it on GitHub https://github.com/PlummersSoftwareLLC/Primes/pull/929#issuecomment-1602748796, or unsubscribe https://github.com/notifications/unsubscribe-auth/AA4HCF5BICD3NKWG2LV6SL3XMRJR7ANCNFSM6AAAAAAZLALXLY. You are receiving this because you were mentioned.

rbergen commented 1 year ago

I'll take that as a "no objections" 😄