Тёмный

Speeding Up Python Code With Caching 

NeuralNine
Подписаться 372 тыс.
Просмотров 40 тыс.
50% 1

Опубликовано:

 

30 сен 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 76   
@SparePlayss
@SparePlayss 3 года назад
ahh... lemme cache my hello world program now
@NeuralNine
@NeuralNine 3 года назад
😂
@mohamedhabas7391
@mohamedhabas7391 3 года назад
More of this content please !! actual real life use-full things thank you for the hard-work
@NeuralNine
@NeuralNine 3 года назад
thanks for your kind words :)
@ikki411
@ikki411 3 года назад
I just found out that the cache decorator was added in Python version 3.9, so those who are in a previous version have to use lru_cache instead.
@zombiekiller7101
@zombiekiller7101 3 года назад
You can increase the recursion limit using sys module import sys sys.setrecursionlimit(10**12)
@NeuralNine
@NeuralNine 3 года назад
oh very good to know. Didn't know that ^^
@marcoh2537
@marcoh2537 3 года назад
Nice to know, but it looks like a dangerous tool to use!
@RealistikDash
@RealistikDash 3 года назад
Be careful setting it too high. Too much recursion will cause a Segmentation Fault.
@learntocode5464
@learntocode5464 2 года назад
OverflowError: Python int too large to convert to C int
@Rade34
@Rade34 3 года назад
Search: Emanuel Swedenborg
@switchblade3868
@switchblade3868 3 года назад
When recommendation is faster than notification
@mr.lawliet
@mr.lawliet 3 года назад
When I saw it I just hoped that it wasn’t an april fools
@NeuralNine
@NeuralNine 3 года назад
That would not be the most catchy title for a joke xD
@gerokatseros
@gerokatseros 3 года назад
my python 3.9 functools dont have @cache anymore i think , i get an error whereas @lru_cache works
@leifleoden5464
@leifleoden5464 2 года назад
Me: "How do I do caching in python... I bet there's a module for this." NeuralNine: "yeah 'from functools import cache' " Perfect video, it's rare that you get the exact answer you are looking for with a walk through right away. I love the future!
@cagataydemirbas7259
@cagataydemirbas7259 2 года назад
for me it isnt working. with cache and without cache always shows same time idk why
@pandasleaf9629
@pandasleaf9629 2 месяца назад
Thank you for this sir! (Watching from Philippines)
@phinguyen4823
@phinguyen4823 3 года назад
this cache is similar to the idea of dynamic - save some part of the result
@rizkyagungshahputra215
@rizkyagungshahputra215 3 года назад
I had already tried to import cache from functool in google colab but it got an error, do you know why this happens? So instead i import Cache from cache-decorator
@nileshchaudhary1643
@nileshchaudhary1643 3 года назад
explanation is too clear !!!
@IzUrBoiKK
@IzUrBoiKK 3 года назад
Pycharm? Vscode pls!
@ishaandugar7896
@ishaandugar7896 3 года назад
Ok, so if I have a pyinstaller .exe onefile, will cache speed that up too?
@destiny_02
@destiny_02 3 года назад
Yes, Pyinstaller exe is basically a self extracting archive.
@abdellasolomon6244
@abdellasolomon6244 3 года назад
I want to know this too
@boxtalks7994
@boxtalks7994 3 года назад
Yeah all pyinstaller does is bundle the whole python runtime with the code, it won’t be any faster. So yes, this will increase execution speeds. One note, if you are using linux or cygwin you can install cython to compile python to C, that would result in super fast execution times.
@ishaandugar7896
@ishaandugar7896 3 года назад
@@boxtalks7994 Oh great. Thanks!
@kcvinu
@kcvinu Год назад
Why did time.time() function is useless for results under one seconds ? In fact, executing code is happening in microseconds and milliseconds.
@hebasiddig7475
@hebasiddig7475 26 дней назад
Thank youuuu
@GodbornNoven
@GodbornNoven Год назад
Caching data basically means you're decreasing the amount of calculations you need to do by optimizing the process through which the calculations are done. But heres what im confused about. Why does caching make it THAT much faster? Here you're decreasing the number of calculations u need to do by half (or is that more than half) so why is it so significantly faster Found my answer. The decrease in calculations is significantly more than half. The Fibonacci sequence is super unoptimized
@MrRezhes
@MrRezhes Год назад
Thank u, and is there anyway u could make a video on Cython, Numba, or any other library helping speed ups?
@Hello_-_-_-_
@Hello_-_-_-_ 10 месяцев назад
That is awesome
@thomasgoodwin2648
@thomasgoodwin2648 3 года назад
When caching is used in calculations like this the technique is often called 'memoization'. Also quite handy when writing a prime factor sieve. Love the channel. Long live human 2.0. Go SpaceX.
@rangabharath4253
@rangabharath4253 3 года назад
Awesome as always 👍😀
@NeuralNine
@NeuralNine 3 года назад
thanks ^^
@pepecopter
@pepecopter Год назад
Amazing thanks
@cestlacroix
@cestlacroix 2 года назад
🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥
@Manishdna
@Manishdna 3 года назад
This is awesome! Learned much about it!
@learntocode5464
@learntocode5464 2 года назад
awesome toturial, thanks. but can we know how the cache function acts or not, and can we write a normal function acts like a built-in cache function.
@mikelemon5109
@mikelemon5109 3 года назад
Where can you learn about this caching from first principles?
@thehobsshow399
@thehobsshow399 3 года назад
april first lol
@rugmaable
@rugmaable 8 месяцев назад
amazing video and content. Straight to the point.
@cybersecurity3523
@cybersecurity3523 3 года назад
Hello bro can you explain pwntools python library
@parthadey1888
@parthadey1888 2 года назад
Cool.....
@ikpesuemmanuel7359
@ikpesuemmanuel7359 2 года назад
Does caching have a negative side?
@ikpesuemmanuel7359
@ikpesuemmanuel7359 Год назад
@benoitgael2969 Thank you
@muskankushwah2256
@muskankushwah2256 2 года назад
amazing video , just love it.
@workcontact9726
@workcontact9726 Год назад
can you help me 🤦‍♀🚨🚨 TypeError: unhashable type: 'numpy.ndarray'
@Thokpower1
@Thokpower1 3 года назад
Actually learned so much from this. Decorators finally make sense and I found a way to speed up my python programs
@سهرابمرادی-ك3ه
@سهرابمرادی-ك3ه 3 года назад
It was very helpful for me.
@सुरेलसंवादिनी
But Pycharm is heavy
@victordvickie
@victordvickie 3 года назад
Do a video about cython
@christiankoch4627
@christiankoch4627 3 года назад
And now should i Cache every function?
@Unreql
@Unreql 3 года назад
I think you would only need to do it on iterative functions, if you wanna learn more about this sort of "caching" data to speedup programs, FreeCodeCamp have a dynamic programming tutorial which basically explains how to do caching and speedup this function with code and not just a decorator. It's nice to see how things work :)
@LukieHZX
@LukieHZX 3 года назад
Wieso wieder PyCharm?
@rabiumuhammedeffect423
@rabiumuhammedeffect423 3 года назад
Good better and best
@akshatdodhiya
@akshatdodhiya 3 года назад
Loved your intro music! The video as well. You're awesome and unique as always :)
@shubhamg9495
@shubhamg9495 3 года назад
Thank you so much.
@oliverli9630
@oliverli9630 2 года назад
that's nice!!
@MagnusAnand
@MagnusAnand 2 года назад
Cool video!
@brantechsyt6130
@brantechsyt6130 3 года назад
Nice video
@b1ack_c0de
@b1ack_c0de 3 года назад
Thanks
@hoyinli7462
@hoyinli7462 3 года назад
great
@omaral-halabiah2851
@omaral-halabiah2851 3 года назад
helpful
@__3093
@__3093 3 года назад
YES
@bhavyamverma70
@bhavyamverma70 3 года назад
2nd
@NeuralNine
@NeuralNine 3 года назад
👍
@jfklittle
@jfklittle 3 года назад
when i am working with classes and "@property" can i use the "@cache" too???
@tips1483
@tips1483 3 года назад
1st
@NeuralNine
@NeuralNine 3 года назад
^^
@falxie_
@falxie_ 3 года назад
Might've been useful to show how to implement caching like that instead of just importing
@jonasstrabel
@jonasstrabel 3 года назад
Where have I seen this video before...? You copied that from someone right?
@jonasstrabel
@jonasstrabel 3 года назад
Ah, the video from mCoding!
@mehrdad-mixtape7970
@mehrdad-mixtape7970 3 года назад
Hi bro, Thanks for tutorial. but I have problem for this: from functools import cache when I run my code give me error: ImportError: cannot import name 'cache' from 'functools' (/usr/lib/python3.8/functools.py)
@beach2550
@beach2550 3 года назад
`cache` was added to python 3.9. You will have to use `@functools.lru_cache(maxsize=None)` for the same effect as `@functools.cache` So just import `lru_cache` from functools
Далее
Make Python code 1000x Faster with Numba
20:33
Просмотров 444 тыс.
Speed Up Your Code With Cython
16:37
Просмотров 117 тыс.
КВН 2024 Встреча выпускников
2:00:41
Please Master These 10 Python Functions…
22:17
Просмотров 165 тыс.
SPEED UP Python with caching
10:36
Просмотров 2,5 тыс.
Don't Keep Requesting API Data, DO THIS!
9:52
Просмотров 11 тыс.
I used to hate QR codes. But they're actually genius
35:13
Compiled Python is FAST
12:57
Просмотров 111 тыс.
25 nooby Python habits you need to ditch
9:12
Просмотров 1,8 млн
Python and Redis Tutorial - Caching API Responses
32:26
Speed Up your Python Apps with Caching
43:17
Просмотров 2,2 тыс.
5 Useful Python Decorators (ft. Carberra)
14:34
Просмотров 101 тыс.
КВН 2024 Встреча выпускников
2:00:41