-
-
Notifications
You must be signed in to change notification settings - Fork 44.4k
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
Importance of caching algorithms #8083
Comments
@cclauss Maybe it could be in the form of adding another function with caching implemented, or mentioning it in the README, or having notes in the docstrings about caching. What is your opinion? |
I love the notion for side-by-side implementations without cache and with cache. The first would be easier to read / understand and the second would be more performant. We would need |
Awesome, I will make some pull requests implementing this |
Feature description
This is an algorithms-based repository, which does not necessarily focus on time complexity, but also on readability and understandability. That being said, specific algorithms are benchmarked for speed comparisons, and sometimes implementing a caching system vastly improves this speed.
For example, if the recursive
fibonacci
function found herehttps://github.com/TheAlgorithms/Python/blob/master/maths/fibonacci.py#L63
is timed and produces an average speed of
6.0ms
, on my machine at least. however when you implement the functoolslru_cache
, it speeds the algorithm to0.0ms
, to match the other algorithms.The example with caching:
The text was updated successfully, but these errors were encountered: