[issue36485] Add a way to clear all caches

Serhiy Storchaka report at bugs.python.org
Sun Mar 31 05:11:32 EDT 2019


Serhiy Storchaka <storchaka+cpython at gmail.com> added the comment:

My initial idea was to add a lightweight module cachesreg with two functions: register() and clear_caches(). PR 12639 implements it.

But I like Brett's idea more, because it is simpler. The only disadvantage of it is that if you make a typo in __clearcache__, this function will be silently ignored.

I thought also about different levels of cachesreg.cachesreg.register() could take two arguments -- the level and the clearing function. Then cachesreg.clear_caches() could allow to clear only caches of specified level and smaller/larger.

Both PRs add clearing callbacks only for modules which already cleared in regrtests. There are more caches, and with implementing any of these ideas it will be easier to add clearing caches in other modules.

----------

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


More information about the Python-bugs-list mailing list