Talk Python To Me cover image

#28: Making Python Fast: Profiling Python Code

Talk Python To Me

Code Ship: How to Create a Python Dictionary That Caches Out Function Arguments

2min Snip

00:00
Play full episode
A decorator can only call a function if it's never seen the inputs before. It adds an internal cache, which is just a Python dictionary that keeps the function arguments as the key and the output of the function as the value. So what all it needs to do is a simple dictionary call. And for the amount of words in the English language that are primarily used, it'll be called much less.

Get the Snipd
podcast app

Unlock the knowledge in podcasts with the podcast player of the future.
App store bannerPlay store banner

AI-powered
podcast player

Listen to all your favourite podcasts with AI-powered features

Discover
highlights

Listen to the best highlights from the podcasts you love and dive into the full episode

Save any
moment

Hear something you like? Tap your headphones to save it with AI-generated key takeaways

Share
& Export

Send highlights to Twitter, WhatsApp or export them to Notion, Readwise & more

AI-powered
podcast player

Listen to all your favourite podcasts with AI-powered features

Discover
highlights

Listen to the best highlights from the podcasts you love and dive into the full episode