Yury Selivanov added the comment:

> Good sleuthing! So the bug is in _lru_cache?

I don't think it's a bug of lru_cache. It stores strong references for 
arguments and return value of the decorated function (which btw isn't 
documented).  I don't think it's possible to write efficient generic lru_cache 
that would just use weakrefs.

The problem is that because _tp_cache helper uses it, the lifetime of some 
typing classes becomes indefinite.  Which shouldn't be a problem for a typical 
user of typing, since most of the time it is used on the module level.

We have two potential solutions to this problem:

1. Add a weak-ref type cache and refactor _tp_cache to use it;

2. Cleanup lru-cache before/adter running each typing test.

[1] is the ideal solution, [2] should work good enough.

----------

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

Reply via email to