Advanced Concepts for Self-taught Devs: Intro to Memoization in Python

Photo by Sean Lim on Unsplash

So what is memoization?

Let’s walk through what this might look like in theory.

  1. g(x) -> checks to see if we’ve already done f(x) and have the results stored
  2. If we do, it immediately returns the results.
  3. If we don’t, it executes f(x)
  4. It then caches the result for future use
  5. Then, it returns the result.

cache = {‘x’ : ‘y’}

So what is a decorator?

--

--

--

Cofounder and CEO @ Agency // GetAgency.com // YC W22, Startups, Software, Cybersecurity, & Privacy.

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Algorithms: Maximum Product Subarray

Maximum product subarray banner image

PokeSwap Launch Recap

Export Pandas Dataframe Using Python

Monitoring event-driven pipelines — now for real

To launch Webserver with AWS using Terraform code

Setup MongoDB Replica set with Authentication using Docker

CS 371p Spring 2020: Vihaarika Vysyaraju Week 5

Reducing callback redundancy with Kotlin extension in Android

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Amir Tarighat

Amir Tarighat

Cofounder and CEO @ Agency // GetAgency.com // YC W22, Startups, Software, Cybersecurity, & Privacy.

More from Medium

Python Basics: 06 taking user input

Python’s Types Live with Objects, Variables are Relative

Python Unknown (Tips and Tricks) — Part 3

Concept of Time complexity with Python Examples