Serhiy Storchaka added the comment:

> Perhaps:  _cache.pop(next(iter(_cache)))

This can raise KeyError if the cache is cleared in other thread. And it is a 
little slower.

I remember why I didn't propose this idea earlier. This depends on the ordering 
of dict. But this is implementation detail, and in other Python implementation 
this can cause recompiling two interchangeably used regexes. No, this no longer 
LGTM.

Maybe use OrderedDict? But this adds heavy dependency to the re module.

Yet one idea: use two caches. Look first in the one cache, then in the other. 
When the first cache full, clear the second cache and swap caches.

----------

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

Reply via email to