You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When you begin writing code, and the plan changes half way through it's easy for bottlenecks that weren't previously a problem to appear. These can be recognised and easily addressed, they mostly revolve around redundant repetition.
Repeating the same operation to calculate a value every iteration of a loop (move the operation outside the loop so that it's performed once)
Regularly calling a function that performs an expensive operation to return a predictable result (cache results, LRU cache decorator).
Reading the same file from disk multiple times (read it once and cache it in memory).
??
The text was updated successfully, but these errors were encountered:
Regularly calling a function that performs an expensive operation to return a predictable result (cache results, LRU cache decorator).
Yes—memoization was also on the list of things I considered adding (but didn’t get to for our first run). With [functools.cache](https://docs.python.org/3/library/functools.html#functools.cache), that’s just a 1 line change, so hopefully shouldn’t take up too much time? Factorial or Fibonacci could both make for a good demo.
Similar to the short snippet about filter your data before processing not after, it feels too short/brief for people to take it in. Lack of a decent example stopped me adding this, functools cache could work though.
When you begin writing code, and the plan changes half way through it's easy for bottlenecks that weren't previously a problem to appear. These can be recognised and easily addressed, they mostly revolve around redundant repetition.
The text was updated successfully, but these errors were encountered: