當前位置: 首頁>>代碼示例>>Python>>正文


Python lru.LRU屬性代碼示例

本文整理匯總了Python中lru.LRU屬性的典型用法代碼示例。如果您正苦於以下問題:Python lru.LRU屬性的具體用法?Python lru.LRU怎麽用?Python lru.LRU使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在lru的用法示例。


在下文中一共展示了lru.LRU屬性的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: check

# 需要導入模塊: import lru [as 別名]
# 或者: from lru import LRU [as 別名]
def check(self, host_port, key):
        """
        判斷key是否存在於lru中,不存在則加入

        Parameters:
            host_port - host + "_" + str(port) 組成的字符串,指定查找的LRU
            key - 在LRU中查找的key

        Raises:
            KeyError - key不存在於LRU中
        """
        try:
            target_lru = self.lru_dict[host_port]
        except KeyError:
            self.lru_dict[host_port] = lru.LRU(self.max_size)
            self.lru_dict[host_port][key] = None
            raise KeyError

        try:
            target_lru[key]
        except KeyError:
            target_lru[key] = None
            raise KeyError 
開發者ID:baidu-security,項目名稱:openrasp-iast,代碼行數:25,代碼來源:preprocessor.py

示例2: __init__

# 需要導入模塊: import lru [as 別名]
# 或者: from lru import LRU [as 別名]
def __init__(self, trading_calendar, reader, equity_adjustment_reader,
                 asset_finder,
                 roll_finders=None,
                 sid_cache_size=1000,
                 prefetch_length=0):
        self.trading_calendar = trading_calendar
        self._asset_finder = asset_finder
        self._reader = reader
        self._adjustment_readers = {}
        if equity_adjustment_reader is not None:
            self._adjustment_readers[Equity] = \
                HistoryCompatibleUSEquityAdjustmentReader(
                    equity_adjustment_reader)
        if roll_finders:
            self._adjustment_readers[ContinuousFuture] =\
                ContinuousFutureAdjustmentReader(trading_calendar,
                                                 asset_finder,
                                                 reader,
                                                 roll_finders,
                                                 self._frequency)
        self._window_blocks = {
            field: ExpiringCache(LRU(sid_cache_size))
            for field in self.FIELDS
        }
        self._prefetch_length = prefetch_length 
開發者ID:enigmampc,項目名稱:catalyst,代碼行數:27,代碼來源:history_loader.py

示例3: __init__

# 需要導入模塊: import lru [as 別名]
# 或者: from lru import LRU [as 別名]
def __init__(self, *args, cache=None, **kwargs):
        arg_names = self._meta.field_names or ()
        validate_args_and_kwargs(args, kwargs, arg_names)
        field_values = merge_kwargs_to_args(args, kwargs, arg_names)

        # Ensure that all the fields have been given values in initialization
        if len(field_values) != len(arg_names):
            raise TypeError(
                "Argument count mismatch. expected {0} - got {1} - missing {2}".format(
                    len(arg_names),
                    len(field_values),
                    ",".join(arg_names[len(field_values) :]),
                )
            )

        for value, attr in zip(field_values, self._meta.field_attrs or ()):
            setattr(self, attr, make_immutable(value))

        self.cache = LRU(DEFAULT_CACHE_SIZE) if cache is None else cache 
開發者ID:ethereum,項目名稱:py-ssz,代碼行數:21,代碼來源:serializable.py

示例4: delete_key

# 需要導入模塊: import lru [as 別名]
# 或者: from lru import LRU [as 別名]
def delete_key(self, host_port, key):
        """
        在LRU中刪除指定的key

        Parameters:
            host_port - host + "_" + str(port) 組成的字符串,指定刪除的key所在的LRU
            key - 在LRU中刪除的key

        """
        try:
            target_lru = self.lru_dict[host_port]
            del target_lru[key]
        except KeyError:
            pass 
開發者ID:baidu-security,項目名稱:openrasp-iast,代碼行數:16,代碼來源:preprocessor.py

示例5: clean_lru

# 需要導入模塊: import lru [as 別名]
# 或者: from lru import LRU [as 別名]
def clean_lru(self, host_port):
        """
        清空LRU

        Parameters:
            host_port - host + "_" + str(port) 組成的字符串,指定清空的LRU
        """
        self.lru_dict.pop(host_port, None) 
開發者ID:baidu-security,項目名稱:openrasp-iast,代碼行數:10,代碼來源:preprocessor.py

示例6: __init__

# 需要導入模塊: import lru [as 別名]
# 或者: from lru import LRU [as 別名]
def __init__(self):
		self._cache = LRU(30)
		self._LRULock = threading.RLock() 
開發者ID:imiyoo2010,項目名稱:teye_scanner_for_book,代碼行數:5,代碼來源:dpCache.py

示例7: reset_cache

# 需要導入模塊: import lru [as 別名]
# 或者: from lru import LRU [as 別名]
def reset_cache(self) -> None:
        self._cached_values = LRU(self._cache_size) 
開發者ID:ethereum,項目名稱:py-evm,代碼行數:4,代碼來源:cache.py

示例8: __init__

# 需要導入模塊: import lru [as 別名]
# 或者: from lru import LRU [as 別名]
def __init__(self,
                 chain_db: ChainDatabaseAPI,
                 epoch_length: int) -> None:
        self._chain_db = chain_db
        self._epoch_length = epoch_length
        self._snapshots = lru.LRU(IN_MEMORY_SNAPSHOTS) 
開發者ID:ethereum,項目名稱:py-evm,代碼行數:8,代碼來源:snapshot_manager.py

示例9: clear

# 需要導入模塊: import lru [as 別名]
# 或者: from lru import LRU [as 別名]
def clear(self) -> None:
        self._cached_values = LRU(self._cache_size) 
開發者ID:ethereum,項目名稱:py-ssz,代碼行數:4,代碼來源:cache.py

示例10: __init__

# 需要導入模塊: import lru [as 別名]
# 或者: from lru import LRU [as 別名]
def __init__(self, cache_size):
        self.certificates = LRU(cache_size) 
開發者ID:lyft,項目名稱:confidant,代碼行數:4,代碼來源:certificatemanager.py

示例11: clear_cache

# 需要導入模塊: import lru [as 別名]
# 或者: from lru import LRU [as 別名]
def clear_cache(self):
        if self._caches is None:
            self._caches = LRU(self.MAX_CACHE_SPACE // self.CACHE_LENGTH)
        else:
            self._caches.clear() 
開發者ID:DingTobest,項目名稱:Rqalpha-myquant-learning,代碼行數:7,代碼來源:cache.py

示例12: __init__

# 需要導入模塊: import lru [as 別名]
# 或者: from lru import LRU [as 別名]
def __init__(self, rootdir=FXDAYU_BUNDLE_PATH, sid_cache_size=1000, converter=StockBarConverter,
                 trading_session=ASTOCK_TRADING_SESSION):
        minutes_dir = os.path.join(rootdir if rootdir is not None else FXDAYU_BUNDLE_PATH, "minutes")
        super(AStockBcolzMinuteBarReader, self).__init__(minutes_dir, sid_cache_size=sid_cache_size)
        self._index_skip_suspending = LRU(sid_cache_size)
        self._converter = converter
        self._minute_index = _calc_minute_index(self._market_opens, trading_session) 
開發者ID:DingTobest,項目名稱:Rqalpha-myquant-learning,代碼行數:9,代碼來源:astock_minute_reader.py

示例13: __init__

# 需要導入模塊: import lru [as 別名]
# 或者: from lru import LRU [as 別名]
def __init__(self):
        self.cache = LRU(400)
        self.input_shape = None
        self.nb_classes = None
        self.model = None
        self.config = None 
開發者ID:chen0040,項目名稱:keras-audio,代碼行數:8,代碼來源:resnet_v2.py

示例14: __init__

# 需要導入模塊: import lru [as 別名]
# 或者: from lru import LRU [as 別名]
def __init__(self, model_ctx=mx.cpu(), data_ctx=mx.cpu()):
        self.cache = LRU(400)
        self.input_shape = None
        self.nb_classes = None
        self.model = None
        self.config = None
        self.model_ctx = model_ctx
        self.data_ctx = data_ctx 
開發者ID:chen0040,項目名稱:mxnet-audio,代碼行數:10,代碼來源:resnet_v2.py

示例15: __init__

# 需要導入模塊: import lru [as 別名]
# 或者: from lru import LRU [as 別名]
def __init__(self, rootdir, sid_cache_size=1000):
        self._rootdir = rootdir

        metadata = self._get_metadata()

        self._start_session = metadata.start_session
        self._end_session = metadata.end_session

        self.calendar = metadata.calendar
        slicer = self.calendar.schedule.index.slice_indexer(
            self._start_session,
            self._end_session,
        )
        self._schedule = self.calendar.schedule[slicer]
        self._market_opens = self._schedule.market_open
        self._market_open_values = self._market_opens.values. \
            astype('datetime64[m]').astype(np.int64)
        self._market_closes = self._schedule.market_close
        self._market_close_values = self._market_closes.values. \
            astype('datetime64[m]').astype(np.int64)

        self._default_ohlc_inverse = 1.0 / metadata.default_ohlc_ratio
        ohlc_ratios = metadata.ohlc_ratios_per_sid
        if ohlc_ratios:
            self._ohlc_inverses_per_sid = (
                valmap(lambda x: 1.0 / x, ohlc_ratios))
        else:
            self._ohlc_inverses_per_sid = None

        self._minutes_per_day = metadata.minutes_per_day

        self._carrays = {
            field: LRU(sid_cache_size)
            for field in self.FIELDS
        }

        self._last_get_value_dt_position = None
        self._last_get_value_dt_value = None

        # This is to avoid any bad data or other performance-killing situation
        # where there a consecutive streak of 0 (no volume) starting at an
        # asset's start date.
        # if asset 1 started on 2015-01-03 but its first trade is 2015-01-06
        # 10:31 AM US/Eastern, this dict would store {1: 23675971},
        # which is the minute epoch of that date.
        self._known_zero_volume_dict = {} 
開發者ID:enigmampc,項目名稱:catalyst,代碼行數:48,代碼來源:minute_bars.py


注:本文中的lru.LRU屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。