pickleshare.py 文件源码

python
阅读 14 收藏 0 点赞 0 评论 0

项目:blender 作者: gastrodia 项目源码 文件源码
def __getitem__(self,key):
        """ db['key'] reading """
        fil = self.root / key
        try:
            mtime = (fil.stat()[stat.ST_MTIME])
        except OSError:
            raise KeyError(key)

        if fil in self.cache and mtime == self.cache[fil][1]:
            return self.cache[fil][0]
        try:
            # The cached item has expired, need to read
            with fil.open("rb") as f:
                obj = pickle.loads(f.read())
        except:
            raise KeyError(key)

        self.cache[fil] = (obj,mtime)
        return obj
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号