[New-bugs-announce] [issue33774] Improve doc of @lru_cache to avoid misuse and confusion

Al-Scandar Solstag report at bugs.python.org
Tue Jun 5 12:58:55 EDT 2018


New submission from Al-Scandar Solstag <solstag at member.fsf.org>:

Ni!

It is not clear at all in the documentation of @lru_cache that the cache takes into account the exact way the function was called, not the values passed to its arguments, as one could/would expect.

I mean that for function(a, b, c=3) the three calls below are not considered equivalent as far as the cache is concerned:

function(1, 2, 3)
function(1, 2, c=3)
function(1, 2)

I hope this can be clarified in the documentation. I wasted a great deal of time today trying to understand why my calls were not getting cached and only figured it out when I decided to go read @lru_cache's code.

It seems very likely that other people have had the same problem. Or worse, people might be using @lru_cache believing it is working when it isn't.

Cheers!

----------
assignee: docs at python
components: Documentation
messages: 318770
nosy: docs at python, solstag
priority: normal
severity: normal
status: open
title: Improve doc of @lru_cache to avoid misuse and confusion

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue33774>
_______________________________________


More information about the New-bugs-announce mailing list