Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimized python 25 passes -> 4,848 passes #15

Closed
wants to merge 2 commits into from
Closed

Optimized python 25 passes -> 4,848 passes #15

wants to merge 2 commits into from

Conversation

michhernand
Copy link

Changes include:

  1. Adding numpy library and using arrays instead of lists. This optimization results in about a 100% speed improvement.
  2. The real improvement comes from numba, which builds off of numpy and jit compiles our primary worker function. This optimization results in about a 19,000% speed improvement.
  3. Also refactored to a more function-based approach.
  4. Added ability to pass arguments (with default values) via command line.

Michael Hernandez added 2 commits March 26, 2021 01:45
Added numpy and numba for python optimization.
Benchmarks on Core-i5 Laptop Running Windows (Using a limit of 1,000,000):
*Measured in number of passes in 5 seconds*

Original Version:              25
Numpy Optimized (without JIT): 57   (128% improvement)
Numba Optimized (with JIT):    4848 (19,292% improvement)

Other changes include:
- Refactoring to use functions (for debugging numba).
- Added ability to pass args via command line.
@michhernand
Copy link
Author

Closing as #9 seems equally or more optimal - and closer to the original source

@davepl
Copy link
Contributor

davepl commented Mar 26, 2021 via email

@michhernand
Copy link
Author

Makes sense! Would love to see a sequel to this comparison with additional packages / frameworks included.

Btw - great videos! Keep them coming.

callowaysutton added a commit to callowaysutton/Primes that referenced this pull request Mar 29, 2021
435,000% improvement on PlummersSoftwareLLC#15 's 19,000% improvement on the original version by using the Python 3 built-in LRU Caching decorator. Can be used in Python 2.7 by installing the functools library as well.

This should be competitive with even the C++ version :D
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants