const_fold.py 文件源码

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

项目:fatoptimizer 作者: vstinner 项目源码 文件源码
def compare_contains(self, node):
        seq_ast = node.comparators[0]
        if not isinstance(seq_ast, (ast.Set, ast.List)):
            return

        # elements must be hashable
        seq = get_literal(seq_ast, constant_items=True)
        if seq is UNSET:
            return

        if isinstance(seq_ast, ast.Set):
            seq = frozenset(seq)
        else:
            seq = tuple(seq)

        new_seq_ast = self.new_constant(seq_ast, seq)
        if new_seq_ast is None:
            return

        new_node = copy_node(node)
        new_node.comparators[0] = new_seq_ast
        return new_node
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号