Raymond Hettinger <raymond.hettin...@gmail.com> added the comment:

Thanks for the report but this is an allowed behavior and not a bug.
Per the docs¹:  If typed is set to true, function arguments of different types 
will be cached separately. For example, f(3) and f(3.0) will always be treated 
as distinct calls with distinct results. If typed is false, the implementation 
will usually but not always regard them as equivalent calls and only cache a 
single result. 

¹ https://docs.python.org/3.10/library/functools.html#module-functools

In this particular case, exact type matches for str and int have an alternate 
path that tends to save space.

The cost is that str or int equivalents are cached separately.  That doesn't 
tend to be a problem in practice because functions are mostly called with the 
same types over and over again.

Note, we also treat equivalent calling patterns as distinct, f(a=1, b=2), is 
cached separately from f(b=2, a=1).

----------
nosy: +rhettinger
resolution:  -> not a bug
stage:  -> resolved
status: open -> closed

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue44992>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to