@Memoize doesn't work in Python 3 ? -- (Gauche scheme?)

Liste des GroupesRevenir à cl misc 
Sujet : @Memoize doesn't work in Python 3 ? -- (Gauche scheme?)
De : HenHanna (at) *nospam* devnull.tb (HenHanna)
Groupes : comp.lang.python comp.lang.lisp comp.lang.misc
Date : 29. Jul 2024, 19:42:32
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <v88nqo$jkm6$1@dont-email.me>
User-Agent : Mozilla Thunderbird
@Memoize   doesn't  work  in Python 3  ?
Do we have this in  Gauche scheme?  (Common Lisp?)
___________________________
A feature known as "decorators" was added in Python 2.4
@Memoize
def factorial(k):
     if k < 2: return 1
     return k * factorial(k - 1)
__________________________
Python 3.9 released a new function functools.cache.
It caches in memory the result of a function called with a particular set of arguments.
import functools
import time
@functools.cache
def calculate_double(num):
     time.sleep(1) # sleep for 1 second to simulate a slow calculation
     return num * 2

Date Sujet#  Auteur
29 Jul 24 * @Memoize doesn't work in Python 3 ? -- (Gauche scheme?)2HenHanna
30 Jul 24 `- Re: @Memoize doesn't work in Python 3 ? -- (Gauche scheme?)1Kaz Kylheku

Haut de la page

Les messages affichés proviennent d'usenet.

NewsPortal