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 brilee, rhettinger
Date 2021-08-24.16:17:53
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1629821873.78.0.652244344422.issue44992@roundup.psfhosted.org>
In-reply-to
Content
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).
History
Date User Action Args
2021-08-24 16:17:53rhettingersetrecipients: + rhettinger, brilee
2021-08-24 16:17:53rhettingersetmessageid: <1629821873.78.0.652244344422.issue44992@roundup.psfhosted.org>
2021-08-24 16:17:53rhettingerlinkissue44992 messages
2021-08-24 16:17:53rhettingercreate