当前位置: 首页>>代码示例>>Python>>正文


Python utils.dict_itervalues函数代码示例

本文整理汇总了Python中numba.utils.dict_itervalues函数的典型用法代码示例。如果您正苦于以下问题:Python dict_itervalues函数的具体用法?Python dict_itervalues怎么用?Python dict_itervalues使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了dict_itervalues函数的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: seed_return

 def seed_return(self, typ):
     """Seeding of return value is optional.
     """
     for blk in utils.dict_itervalues(self.blocks):
         inst = blk.terminator
         if isinstance(inst, ir.Return):
             self.typevars[inst.value.name].lock(typ)
开发者ID:whalen53,项目名称:numba,代码行数:7,代码来源:typeinfer.py

示例2: run

    def run(self):
        for inst in self._iter_inst():
            fname = "op_%s" % inst.opname
            fn = getattr(self, fname, None)
            if fn is not None:
                fn(inst)
            else:
                assert not inst.is_jump, inst

        # Close all blocks
        for cur, nxt in zip(self.blockseq, self.blockseq[1:]):
            blk = self.blocks[cur]
            if not blk.outgoing_jumps and not blk.terminating:
                blk.outgoing_jumps[nxt] = 0

        graph = CFGraph()
        for b in self.blocks:
            graph.add_node(b)
        for b in self.blocks.values():
            for out, pops in b.outgoing_jumps.items():
                graph.add_edge(b.offset, out, pops)
        graph.set_entry_point(min(self.blocks))
        graph.process()
        self.graph = graph

        # Fill incoming
        for b in utils.dict_itervalues(self.blocks):
            for out, pops in b.outgoing_jumps.items():
                self.blocks[out].incoming_jumps[b.offset] = pops

        # Find liveblocks
        self.liveblocks = dict((i, self.blocks[i])
                               for i in self.graph.nodes())

        for lastblk in reversed(self.blockseq):
            if lastblk in self.liveblocks:
                break
        else:
            raise AssertionError("No live block that exits!?")

        # Find backbone
        backbone = self.graph.backbone()
        # Filter out in loop blocks (Assuming no other cyclic control blocks)
        # This is to unavoid variable defined in loops to be considered as
        # function scope.
        inloopblocks = set()

        for b in self.blocks.keys():
            for s, e in self._loops:
                if s <= b < e:
                    inloopblocks.add(b)

        self.backbone = backbone - inloopblocks
开发者ID:ASPP,项目名称:numba,代码行数:53,代码来源:controlflow.py

示例3: _start_new_block

 def _start_new_block(self, inst):
     self.loc = ir.Loc(filename=self.bytecode.filename, line=inst.lineno)
     oldblock = self.current_block
     self.insert_block(inst.offset)
     # Ensure the last block is terminated
     if oldblock is not None and not oldblock.is_terminated:
         jmp = ir.Jump(inst.offset, loc=self.loc)
         oldblock.append(jmp)
         # Get DFA block info
     self.dfainfo = self.dfa.infos[self.current_block_offset]
     self.assigner = Assigner()
     # Notify listeners for the new block
     for fn in utils.dict_itervalues(self._block_actions):
         fn(self.current_block_offset, self.current_block)
开发者ID:Bengt,项目名称:numba,代码行数:14,代码来源:interpreter.py

示例4: run

    def run(self):
        for inst in self._iter_inst():
            fname = "op_%s" % inst.opname
            fn = getattr(self, fname, None)
            if fn is not None:
                fn(inst)
            else:
                assert not inst.is_jump, inst

        # Close all blocks
        for cur, nxt in zip(self.blockseq, self.blockseq[1:]):
            blk = self.blocks[cur]
            if not blk.outgoing and not blk.terminating:
                blk.outgoing.add(nxt)

        # Fill incoming
        for b in utils.dict_itervalues(self.blocks):
            for out in b.outgoing:
                self.blocks[out].incoming.add(b.offset)

        # Find liveblocks
        self.dead_block_elimin()

        # Find dominators
        self.doms = find_dominators(self.liveblocks)

        for lastblk in reversed(self.blockseq):
            if lastblk in self.liveblocks:
                break
        else:
            raise AssertionError("No live block that exits!?")

        # Find backbone
        backbone = set(self.doms[lastblk])
        # Filter out in loop blocks (Assuming no other cyclic control blocks)
        # This is to unavoid variable defined in loops to be considered as
        # function scope.
        inloopblocks = set()

        for b in self.blocks.keys():
            for s, e in self._loops:
                if s <= b < e:
                    inloopblocks.add(b)

        self.backbone = backbone - inloopblocks
开发者ID:B-Rich,项目名称:numba,代码行数:45,代码来源:controlflow.py

示例5: get_return_type

    def get_return_type(self, typemap):
        rettypes = set()
        for blk in utils.dict_itervalues(self.blocks):
            term = blk.terminator
            if isinstance(term, ir.Return):
                rettypes.add(typemap[term.value.name])

        if types.none in rettypes:
            # Special case None return
            rettypes = rettypes - set([types.none])
            if rettypes:
                unified = self.context.unify_types(*rettypes)
                return types.Optional(unified)
            else:
                return types.none
        else:
            unified = self.context.unify_types(*rettypes)
            return unified
开发者ID:albop,项目名称:numba,代码行数:18,代码来源:typeinfer.py

示例6: run_block

    def run_block(self, blk):
        tempassign = {}
        removeset = set()

        for offset, inst in enumerate(blk.body):
            self.mark_asssignment(tempassign, offset, inst)

        for bag in utils.dict_itervalues(tempassign):
            if len(bag) == 2:
                off1, off2 = bag
                first = blk.body[off1]
                second = blk.body[off2]
                inst = ir.Assign(value=first.value, target=second.target, loc=first.loc)
                # Replacement the second instruction
                blk.body[off2] = inst
                # Remove the first
                removeset.add(off1)

        # Remove from the highest offset to the lowest to preserve order
        for off in reversed(sorted(removeset)):
            del blk.body[off]
开发者ID:rayleyva,项目名称:numba,代码行数:21,代码来源:irpasses.py

示例7: dump

 def dump(self):
     for blk in utils.dict_itervalues(self.infos):
         blk.dump()
开发者ID:wojons,项目名称:numba,代码行数:3,代码来源:dataflow.py

示例8: __iter__

 def __iter__(self):
     return utils.dict_itervalues(self.table)
开发者ID:ASPP,项目名称:numba,代码行数:2,代码来源:bytecode.py

示例9: get_state_token

 def get_state_token(self):
     """The algorithm is monotonic.  It can only grow the typesets.
     The sum of all lengths of type sets is a cheap and accurate
     description of our progress.
     """
     return sum(len(tv) for tv in utils.dict_itervalues(self.typevars))
开发者ID:whalen53,项目名称:numba,代码行数:6,代码来源:typeinfer.py

示例10: build_constrain

 def build_constrain(self):
     for blk in utils.dict_itervalues(self.blocks):
         for inst in blk.body:
             self.constrain_statement(inst)
开发者ID:whalen53,项目名称:numba,代码行数:4,代码来源:typeinfer.py

示例11: verify

 def verify(self):
     for b in utils.dict_itervalues(self.blocks):
         b.verify()
开发者ID:B-Rich,项目名称:numba,代码行数:3,代码来源:interpreter.py

示例12: cleanup

 def cleanup(self):
     for var in utils.dict_itervalues(self.varmap):
         self.decref(self.builder.load(var))
开发者ID:B-Rich,项目名称:numba,代码行数:3,代码来源:lowering.py


注:本文中的numba.utils.dict_itervalues函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。