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 jaraco
Recipients jaraco, rhettinger
Date 2019-04-17.18:52:55
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
I've put together this full reproducer script:

import functools

def method_cache(method):
	def wrapper(self, *args, **kwargs):
		# it's the first call, replace the method with a cached, bound method
		bound_method = functools.partial(method, self)
		cached_method = functools.lru_cache()(bound_method)
		setattr(self, method.__name__, cached_method)
		return cached_method(*args, **kwargs)
	return wrapper

class MyClass:
	calls = 0

	def call_me_maybe(self, number):
		self.calls += 1
		return number

ob = MyClass()
assert ob.calls == 1

That code fails on Python 3.7.3. If I bypass the `from _functools import _lru_cache_wrapper` in functools, the test no longer fails, so the issue seems to be only with the C implementation.
Date User Action Args
2019-04-17 18:52:55jaracosetrecipients: + jaraco, rhettinger
2019-04-17 18:52:55jaracosetmessageid: <>
2019-04-17 18:52:55jaracolinkissue36650 messages
2019-04-17 18:52:55jaracocreate