lazyarray.py 文件源码

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

项目:lazyarray 作者: NeuralEnsemble 项目源码 文件源码
def __deepcopy__(self, memo):
        obj = type(self).__new__(type(self))
        if isinstance(self.base_value, VectorizedIterable):  # special case, but perhaps need to rethink
            obj.base_value = self.base_value                 # whether deepcopy is appropriate everywhere
        else:
            try:
                obj.base_value = deepcopy(self.base_value)
            except TypeError:  # base_value cannot be copied, e.g. is a generator (but see generator_tools from PyPI)
                obj.base_value = self.base_value  # so here we create a reference rather than deepcopying - could cause problems
        obj._shape = self._shape
        obj.dtype = self.dtype
        obj.operations = []
        for f, arg in self.operations:
            if isinstance(f, numpy.ufunc):
                obj.operations.append((f, deepcopy(arg)))
            else:
                obj.operations.append((deepcopy(f), deepcopy(arg)))
        return obj
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号