From dfab589beecd4e24a72eb9c8e306b9e5507d6b41 Mon Sep 17 00:00:00 2001 From: Clifford Gama Date: Sat, 1 Nov 2025 12:37:49 +0200 Subject: [PATCH 1/3] Fix cached calls count in factorial example That's 11 caches, from 0 through 10 inclusive. --- Doc/library/functools.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Doc/library/functools.rst b/Doc/library/functools.rst index 37d9f87e7791dc..84231ca5171e8c 100644 --- a/Doc/library/functools.rst +++ b/Doc/library/functools.rst @@ -46,7 +46,7 @@ The :mod:`functools` module defines the following functions: 3628800 >>> factorial(5) # just looks up cached value result 120 - >>> factorial(12) # makes two new recursive calls, the other 10 are cached + >>> factorial(12) # makes two new recursive calls, the other 11 are cached 479001600 The cache is threadsafe so that the wrapped function can be used in From 8d24841a1234c0cf29fbc56b8b910655b6a391af Mon Sep 17 00:00:00 2001 From: Raymond Hettinger Date: Tue, 4 Nov 2025 18:16:31 -0600 Subject: [PATCH 2/3] Update functools.rst Limit the total line length --- Doc/library/functools.rst | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Doc/library/functools.rst b/Doc/library/functools.rst index 84231ca5171e8c..ef38c84adbee70 100644 --- a/Doc/library/functools.rst +++ b/Doc/library/functools.rst @@ -42,11 +42,11 @@ The :mod:`functools` module defines the following functions: def factorial(n): return n * factorial(n-1) if n else 1 - >>> factorial(10) # no previously cached result, makes 11 recursive calls + >>> factorial(10) # no previously cached result, makes 11 recursive calls 3628800 - >>> factorial(5) # just looks up cached value result + >>> factorial(5) # just looks up cached value result 120 - >>> factorial(12) # makes two new recursive calls, the other 11 are cached + >>> factorial(12) # two new recursive calls, factorial(10) is cached 479001600 The cache is threadsafe so that the wrapped function can be used in From 5f353b78170e87858bce5cefcd9337bd6f87ed5c Mon Sep 17 00:00:00 2001 From: Raymond Hettinger Date: Tue, 4 Nov 2025 18:19:18 -0600 Subject: [PATCH 3/3] Update functools.rst Nicer wording --- Doc/library/functools.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Doc/library/functools.rst b/Doc/library/functools.rst index ef38c84adbee70..1d9ac328f32769 100644 --- a/Doc/library/functools.rst +++ b/Doc/library/functools.rst @@ -44,7 +44,7 @@ The :mod:`functools` module defines the following functions: >>> factorial(10) # no previously cached result, makes 11 recursive calls 3628800 - >>> factorial(5) # just looks up cached value result + >>> factorial(5) # no new calls, just returns the cached result 120 >>> factorial(12) # two new recursive calls, factorial(10) is cached 479001600