- Популярные видео
- Авто
- Видео-блоги
- ДТП, аварии
- Для маленьких
- Еда, напитки
- Животные
- Закон и право
- Знаменитости
- Игры
- Искусство
- Комедии
- Красота, мода
- Кулинария, рецепты
- Люди
- Мото
- Музыка
- Мультфильмы
- Наука, технологии
- Новости
- Образование
- Политика
- Праздники
- Приколы
- Природа
- Происшествия
- Путешествия
- Развлечения
- Ржач
- Семья
- Сериалы
- Спорт
- Стиль жизни
- ТВ передачи
- Танцы
- Технологии
- Товары
- Ужасы
- Фильмы
- Шоу-бизнес
- Юмор
Why Your Recursive Python Functions Are So Slow #pythontips #python
Stop recomputing the same values in your recursive functions by using the built-in cache decorator.
Most Python developers ignore this one line, even though it turns exponential complexity into linear performance.
Without a cache, a simple calculation like fib(35) triggers nearly 30 million redundant calls. With the decorator, that count drops to just 36.
It works by remembering every result for a given set of input arguments.
Use cache only for pure functions where the same input always returns the same output.
Watch out for memory leaks, as it never evicts old entries, and avoid using it on methods where it will pin the self object in memory forever.
#python #pythontips #programming #optimization #recursion #softwareengineering #coding #performance #backenddevelopment
Видео Why Your Recursive Python Functions Are So Slow #pythontips #python канала Dev Did You Know
Most Python developers ignore this one line, even though it turns exponential complexity into linear performance.
Without a cache, a simple calculation like fib(35) triggers nearly 30 million redundant calls. With the decorator, that count drops to just 36.
It works by remembering every result for a given set of input arguments.
Use cache only for pure functions where the same input always returns the same output.
Watch out for memory leaks, as it never evicts old entries, and avoid using it on methods where it will pin the self object in memory forever.
#python #pythontips #programming #optimization #recursion #softwareengineering #coding #performance #backenddevelopment
Видео Why Your Recursive Python Functions Are So Slow #pythontips #python канала Dev Did You Know
Комментарии отсутствуют
Информация о видео
20 июля 2026 г. 7:19:37
00:00:59
Другие видео канала




















