mirror of
https://github.com/GAM-team/GAM.git
synced 2026-06-29 18:31:38 +00:00
cachetools 2.1.0
This commit is contained in:
@@ -2,16 +2,25 @@ from __future__ import absolute_import
|
||||
|
||||
import random
|
||||
|
||||
from .cache import Cache
|
||||
from .cache import Cache, _deprecated
|
||||
|
||||
|
||||
# random.choice cannot be pickled in Python 2.7
|
||||
def _choice(seq):
|
||||
return random.choice(seq)
|
||||
|
||||
|
||||
class RRCache(Cache):
|
||||
"""Random Replacement (RR) cache implementation."""
|
||||
|
||||
def __init__(self, maxsize, choice=random.choice, missing=None,
|
||||
def __init__(self, maxsize, choice=random.choice, missing=_deprecated,
|
||||
getsizeof=None):
|
||||
Cache.__init__(self, maxsize, missing, getsizeof)
|
||||
self.__choice = choice
|
||||
# TODO: use None as default, assing to self.choice directly?
|
||||
if choice is random.choice:
|
||||
self.__choice = _choice
|
||||
else:
|
||||
self.__choice = choice
|
||||
|
||||
@property
|
||||
def choice(self):
|
||||
|
||||
Reference in New Issue
Block a user