Raymond Hettinger <[email protected]> added the comment:
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;
}
----------
versions: -Python 2.7, Python 3.4, Python 3.5
_______________________________________
Python tracker <[email protected]>
<https://bugs.python.org/issue35780>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com