I can’t believe you’re getting so worked up about some guy🤨😳👀
Nicole Scherzinger CAN'T BELIEVE Patti LuPone Praised Her Work (Exclusive)
[ENG SUB]✨From Best Friend's Sister to Midnight Obsession—His Little Moon at Last #DRAMA #PureL...
EGG ANTISTRESS😱 I can’t believe it works🤯 #lifehacks #hacks #asmr
I CAN’T BELIEVE IT WORKS😱 Make up lifehack💅🏻 #makeup #makeuplifehacks #lifehacks #hair
I Can't Believe This Worked!!! - Concrete Cooled PC (April Fools 2019)
I can't believe it works
Can’t believe this works! 😆🎶🎹 #pianoteacher #pianolesson #classicalpiano #piano #pianostudent...
I can’t believe it really works!
SAY Tesla's DIVINE PRAYER - You Won't Believe How Fast It Works
Shocking Deep-Sea Colossus – Fishermen Can’t Believe Their Eyes
I can’t believe this works! 😍
I can't believe this worked!! (lemon coffee hack)
CAN’T BELIEVE THIS WORKED! 😱🥛🤣 | Triple Charm #shorts #shorts30
Samsung Z Flip 6 Durability Test - I CANT BELIEVE THIS WORKED...
I Can't Believe This Actually Works!
I can't believe that worked!
Комментарии
Only do that for pure functions! Or else everything will catch fire
cover
Not only it can cause memory leaks, but one may accidentally introduce a bug that will be really hard to catch since cache is a decorator, not in a function itself
Smbrine
Only do this for pure functions - which are functions which ALWAYS return a specific output given a specific input.
kenarnarayaka
@cache
def randomNumber(n):
👁️ 👄 👁️
rutvikrana
Silence, python developers are learning about cache.
ffelegal
This only works for pure functions though
travelan
Don't use it on methods. Pure functions only. Bugs and leaks otherwise.
__mrmino__
Yes this is useful but also very basic. The python decorator is a nice QoL but in general if you care about performance you should do the caching manually using an array or dictionary. Also if you REALLY care about performance, then don't use python⭐️
bloom
Quite often, implementing your own cache can be much faster.
ttoommxxmmoott
What does "input_" do? I mean the underscore after input.
wedgeguyfr
Just don't use this if the function has side effects
MasonSchmidgall
what would happen if there's randomness in the func?
vorkutavorkutlag
Me and my friend were trying to optimize a program, and we turned it into a competition. He used your method. I used a dictionary. My method was significantly faster with only a few more lines than his.
diamond
Python scriptkiddie learns about memoization.
markusklyver
that's wicked. I'm putting that in tomorrow
Robert-qwlr
please guys just read std library first, all those tik-toks style videos is just docs
ordinarygg
if the process is already taking much of the memory, isnt it going to add up quickly with number of calls with different inputs
mpty
Hey! It's nice.
Can you please clarify what's difference between the following two:
1. @lru_cache
2. @cache
lru stands for Least Recently Used. They both decorators come from `functools` library, and work exactly same.
dipeshsamrawat
This can be good but the cache need to be clean or it's automatic and where he's going like ram or ssd ?
Kdr
Don't know why so many people on YouTube are so hyped about this. It's like you never heard of caching before, this approach is extremely limited and only works/benefits algorithms which return a constant result given an input, with these computations most of the time being instantaneous anyways (such as an equation) or precalculated. Not to even mention the memory usage