Speeding Up Python Code With Caching

Speeding Up Python Code With Caching

NeuralNine

3 года назад

39,066 Просмотров

Ссылки и html тэги не поддерживаются


Комментарии:

@Hello_-_-_-_
@Hello_-_-_-_ - 30.11.2023 21:25

That is awesome

Ответить
@workcontact9726
@workcontact9726 - 15.04.2023 05:11

can you help me 🤦‍♀🚨🚨
TypeError: unhashable type: 'numpy.ndarray'

Ответить
@benoitgael2969
@benoitgael2969 - 02.03.2023 18:06

print([fib(n) for n in range(0, 10000)])
something like that with the cache enables python to bypass the maximum depth recursion

Ответить
@pepecopter
@pepecopter - 24.01.2023 23:16

Amazing thanks

Ответить
@MrRezhes
@MrRezhes - 13.01.2023 21:59

Thank u, and is there anyway u could make a video on Cython, Numba, or any other library helping speed ups?

Ответить
@GodbornNoven
@GodbornNoven - 04.12.2022 08:29

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

Ответить
@kcvinu
@kcvinu - 17.11.2022 19:48

Why did time.time() function is useless for results under one seconds ? In fact, executing code is happening in microseconds and milliseconds.

Ответить
@ikpesuemmanuel7359
@ikpesuemmanuel7359 - 17.09.2022 02:15

Does caching have a negative side?

Ответить
@oliverli9630
@oliverli9630 - 31.08.2022 09:24

that's nice!!

Ответить
@IbrokhimAbduvakilov
@IbrokhimAbduvakilov - 24.06.2022 23:35

🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥

Ответить
@parthadey1888
@parthadey1888 - 23.05.2022 22:04

Cool.....

Ответить
@muskankushwah2256
@muskankushwah2256 - 14.05.2022 13:55

amazing video , just love it.

Ответить
@MagnusAnand
@MagnusAnand - 12.04.2022 00:04

Cool video!

Ответить
@cagataydemirbas7259
@cagataydemirbas7259 - 20.01.2022 10:08

for me it isnt working. with cache and without cache always shows same time idk why

Ответить
@leifleoden5464
@leifleoden5464 - 09.12.2021 07:32

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!

Ответить
@learntocode5464
@learntocode5464 - 18.11.2021 14:22

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.

Ответить
@phinguyen4823
@phinguyen4823 - 21.09.2021 18:15

this cache is similar to the idea of dynamic - save some part of the result

Ответить
@hoyinli7462
@hoyinli7462 - 10.09.2021 15:57

great

Ответить
@user-lr1ws6eo5d
@user-lr1ws6eo5d - 03.09.2021 22:03

It was very helpful for me.

Ответить
@mehrdad-mixtape7970
@mehrdad-mixtape7970 - 05.08.2021 10:36

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)

Ответить
@thehobsshow399
@thehobsshow399 - 03.08.2021 02:07

april first lol

Ответить
@shubhamg9495
@shubhamg9495 - 16.06.2021 19:37

Thank you so much.

Ответить
@nileshchaudhary1643
@nileshchaudhary1643 - 05.05.2021 17:57

explanation is too clear !!!

Ответить
@omaral-halabiah2851
@omaral-halabiah2851 - 05.04.2021 11:32

helpful

Ответить
@Manishdna
@Manishdna - 03.04.2021 11:59

This is awesome! Learned much about it!

Ответить
@Thokpower1
@Thokpower1 - 03.04.2021 00:50

Actually learned so much from this. Decorators finally make sense and I found a way to speed up my python programs

Ответить
@falxie_
@falxie_ - 02.04.2021 10:44

Might've been useful to show how to implement caching like that instead of just importing

Ответить
@jonasstrabel
@jonasstrabel - 02.04.2021 00:59

Where have I seen this video before...? You copied that from someone right?

Ответить
@b1ack_c0de
@b1ack_c0de - 02.04.2021 00:23

Thanks

Ответить
@gerokatseros
@gerokatseros - 01.04.2021 22:34

my python 3.9 functools dont have @cache anymore i think , i get an error whereas @lru_cache works

Ответить
@victordvickie
@victordvickie - 01.04.2021 20:16

Do a video about cython

Ответить
@brantechsyt6130
@brantechsyt6130 - 01.04.2021 19:22

Nice video

Ответить
@thomasgoodwin2648
@thomasgoodwin2648 - 01.04.2021 18:43

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.

Ответить
@akshatdodhiya
@akshatdodhiya - 01.04.2021 18:11

Loved your intro music!





The video as well. You're awesome and unique as always :)

Ответить
@ikki411
@ikki411 - 01.04.2021 17:56

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.

Ответить
@mikelemon5109
@mikelemon5109 - 01.04.2021 17:24

Where can you learn about this caching from first principles?

Ответить
@leven5638
@leven5638 - 01.04.2021 15:43

Search: Emanuel Swedenborg

Ответить
@switchblade3868
@switchblade3868 - 01.04.2021 15:17

When recommendation is faster than notification

Ответить
@ThatCoolGuy18
@ThatCoolGuy18 - 01.04.2021 15:15

Pycharm? Vscode pls!

Ответить
@cybersecurity3523
@cybersecurity3523 - 01.04.2021 13:59

Hello bro can you explain pwntools python library

Ответить
@rizkyagungshahputra215
@rizkyagungshahputra215 - 01.04.2021 13:48

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

Ответить
@zombiekiller7101
@zombiekiller7101 - 01.04.2021 13:34

You can increase the recursion limit using sys module

import sys
sys.setrecursionlimit(10**12)

Ответить
@LukieHZX
@LukieHZX - 01.04.2021 13:33

Wieso wieder PyCharm?

Ответить
@ishaandugar7896
@ishaandugar7896 - 01.04.2021 13:29

Ok, so if I have a pyinstaller .exe onefile, will cache speed that up too?

Ответить
@rangabharath4253
@rangabharath4253 - 01.04.2021 13:14

Awesome as always 👍😀

Ответить
@mohamedhabas7391
@mohamedhabas7391 - 01.04.2021 13:09

More of this content please !!
actual real life use-full things
thank you for the hard-work

Ответить
@user-pp6mm5eo7d
@user-pp6mm5eo7d - 01.04.2021 13:00

But Pycharm is heavy

Ответить
@christiankoch4627
@christiankoch4627 - 01.04.2021 12:58

And now should i Cache every function?

Ответить
@jfklittle4272
@jfklittle4272 - 01.04.2021 12:57

when i am working with classes and "@property" can i use the "@cache" too???

Ответить
@mr.lawliet
@mr.lawliet - 01.04.2021 12:52

When I saw it I just hoped that it wasn’t an april fools

Ответить