当前位置: 首页>>代码示例>>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;未经允许,请勿转载。