Mailing List Archive

bpo-33836: Recommend keyword-only param for memoization in FAQ (GH-7687)
https://github.com/python/cpython/commit/2707e41a5c7ede30349cc7dbd66f8be564965d7c
commit: 2707e41a5c7ede30349cc7dbd66f8be564965d7c
branch: master
author: Noah Haasis <haasis_noah@yahoo.de>
committer: Mariatta <Mariatta@users.noreply.github.com>
date: 2018-06-15T20:29:11-07:00
summary:

bpo-33836: Recommend keyword-only param for memoization in FAQ (GH-7687)

Update the the signature in the code example to make `_cache` a keyword-only parameter.

files:
M Doc/faq/programming.rst

diff --git a/Doc/faq/programming.rst b/Doc/faq/programming.rst
index d986ab642bfb..53f3b7f528c0 100644
--- a/Doc/faq/programming.rst
+++ b/Doc/faq/programming.rst
@@ -371,8 +371,8 @@ compute, a common technique is to cache the parameters and the resulting value
of each call to the function, and return the cached value if the same value is
requested again. This is called "memoizing", and can be implemented like this::

- # Callers will never provide a third parameter for this function.
- def expensive(arg1, arg2, _cache={}):
+ # Callers can only provide two parameters and optionally pass _cache by keyword
+ def expensive(arg1, arg2, *, _cache={}):
if (arg1, arg2) in _cache:
return _cache[(arg1, arg2)]


_______________________________________________
Python-checkins mailing list
Python-checkins@python.org
https://mail.python.org/mailman/listinfo/python-checkins
bpo-33836: Recommend keyword-only param for memoization in FAQ (GH-7687) [ In reply to ]
https://github.com/python/cpython/commit/5a0bf74d4ec11a246b401896cbfb2e840c13da40
commit: 5a0bf74d4ec11a246b401896cbfb2e840c13da40
branch: 3.7
author: Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
committer: GitHub <noreply@github.com>
date: 2018-06-15T20:46:30-07:00
summary:

bpo-33836: Recommend keyword-only param for memoization in FAQ (GH-7687)


Update the the signature in the code example to make `_cache` a keyword-only parameter.
(cherry picked from commit 2707e41a5c7ede30349cc7dbd66f8be564965d7c)

Co-authored-by: Noah Haasis <haasis_noah@yahoo.de>

files:
M Doc/faq/programming.rst

diff --git a/Doc/faq/programming.rst b/Doc/faq/programming.rst
index d986ab642bfb..53f3b7f528c0 100644
--- a/Doc/faq/programming.rst
+++ b/Doc/faq/programming.rst
@@ -371,8 +371,8 @@ compute, a common technique is to cache the parameters and the resulting value
of each call to the function, and return the cached value if the same value is
requested again. This is called "memoizing", and can be implemented like this::

- # Callers will never provide a third parameter for this function.
- def expensive(arg1, arg2, _cache={}):
+ # Callers can only provide two parameters and optionally pass _cache by keyword
+ def expensive(arg1, arg2, *, _cache={}):
if (arg1, arg2) in _cache:
return _cache[(arg1, arg2)]


_______________________________________________
Python-checkins mailing list
Python-checkins@python.org
https://mail.python.org/mailman/listinfo/python-checkins
bpo-33836: Recommend keyword-only param for memoization in FAQ (GH-7687) [ In reply to ]
https://github.com/python/cpython/commit/2636833e8e9cb16ba3ae7bf776bbfc91f176367c
commit: 2636833e8e9cb16ba3ae7bf776bbfc91f176367c
branch: 3.6
author: Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
committer: GitHub <noreply@github.com>
date: 2018-06-15T20:50:28-07:00
summary:

bpo-33836: Recommend keyword-only param for memoization in FAQ (GH-7687)


Update the the signature in the code example to make `_cache` a keyword-only parameter.
(cherry picked from commit 2707e41a5c7ede30349cc7dbd66f8be564965d7c)

Co-authored-by: Noah Haasis <haasis_noah@yahoo.de>

files:
M Doc/faq/programming.rst

diff --git a/Doc/faq/programming.rst b/Doc/faq/programming.rst
index 7476ce11f4f1..b717ab8f0f81 100644
--- a/Doc/faq/programming.rst
+++ b/Doc/faq/programming.rst
@@ -371,8 +371,8 @@ compute, a common technique is to cache the parameters and the resulting value
of each call to the function, and return the cached value if the same value is
requested again. This is called "memoizing", and can be implemented like this::

- # Callers will never provide a third parameter for this function.
- def expensive(arg1, arg2, _cache={}):
+ # Callers can only provide two parameters and optionally pass _cache by keyword
+ def expensive(arg1, arg2, *, _cache={}):
if (arg1, arg2) in _cache:
return _cache[(arg1, arg2)]


_______________________________________________
Python-checkins mailing list
Python-checkins@python.org
https://mail.python.org/mailman/listinfo/python-checkins