This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author rhettinger
Recipients rhettinger, serhiy.storchaka
Date 2019-01-19.08:05:50
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1547885150.33.0.728512587132.issue35780@roundup.psfhosted.org>
In-reply-to
Content
Suggested code for the open question listed above:

--- a/Modules/_functoolsmodule.c
+++ b/Modules/_functoolsmodule.c
@@ -733,6 +733,15 @@ lru_cache_make_key(PyObject *args, PyObject *kwds, int typed)

     /* short path, key will match args anyway, which is a tuple */
     if (!typed && !kwds) {
+        if (PyTuple_GET_SIZE(args) == 1) {
+            key = PyTuple_GET_ITEM(args, 0);
+            if (!PySequence_Check(key)) {
+                /* For scalar keys, save space and
+                   drop the enclosing args tuple  */
+                Py_INCREF(key);
+                return key;
+            }
+        }
         Py_INCREF(args);
         return args;
     }
History
Date User Action Args
2019-01-19 08:05:51rhettingersetrecipients: + rhettinger, serhiy.storchaka
2019-01-19 08:05:50rhettingersetmessageid: <1547885150.33.0.728512587132.issue35780@roundup.psfhosted.org>
2019-01-19 08:05:50rhettingerlinkissue35780 messages
2019-01-19 08:05:50rhettingercreate