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


Python moves.intern方法代码示例

本文整理汇总了Python中six.moves.intern方法的典型用法代码示例。如果您正苦于以下问题:Python moves.intern方法的具体用法?Python moves.intern怎么用?Python moves.intern使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在six.moves的用法示例。


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

示例1: __init__

# 需要导入模块: from six import moves [as 别名]
# 或者: from six.moves import intern [as 别名]
def __init__(self, name, filePath, lineNo, attributes, isActive, sysName=None):
    """
    Constructs an anchored probe

    :param name: User friendly name for use in reports
    :param filePath: Path of the source file containing the probe
    :param lineNo: Line number of the statement containing the probe
    :param attributes: Attributes associated with this probe
    :param sysName: Name of the probe, as defined in the instrumented source file
    """
    AbstractProbe.__init__(self, name)
    if not (filePath and lineNo):
      errMsg = """Argument exception - failed to build anchored probe {}.
        must have valid value for <filePath> and <lineNo>""".format(name)
      raise Exception(errMsg)

    self.sysName = sysName
    self.filePath = intern(filePath)
    self.path = intern(os.path.dirname(filePath))
    self.fileName = intern(os.path.basename(filePath))
    self.lineNo = int(lineNo)
    self.attributes = attributes
    self.isActive = isActive
    self.initAttributes() 
开发者ID:Morgan-Stanley,项目名称:Xpedite,代码行数:26,代码来源:probe.py

示例2: add_expression_instruction

# 需要导入模块: from six import moves [as 别名]
# 或者: from six.moves import intern [as 别名]
def add_expression_instruction(self, lhs, rhs):
        scope = self.scope_stack[-1]

        new_id = intern("insn%d" % self.insn_id_counter)
        self.insn_id_counter += 1

        from loopy.kernel.data import Assignment
        insn = Assignment(
                lhs, rhs,
                within_inames=frozenset(
                    scope.active_loopy_inames),
                id=new_id,
                predicates=frozenset(self.conditions),
                tags=tuple(self.instruction_tags))

        scope.previous_instruction_id = new_id
        scope.instructions.append(insn)

    # {{{ map_XXX functions 
开发者ID:inducer,项目名称:loopy,代码行数:21,代码来源:translator.py

示例3: realize_conditional

# 需要导入模块: from six import moves [as 别名]
# 或者: from six.moves import intern [as 别名]
def realize_conditional(self, node, context_cond=None):
        scope = self.scope_stack[-1]

        cond_name = intern("loopy_cond%d" % self.condition_id_counter)
        self.condition_id_counter += 1
        assert cond_name not in scope.type_map

        scope.type_map[cond_name] = np.int32

        from pymbolic import var
        cond_var = var(cond_name)

        self.add_expression_instruction(
                cond_var, self.parse_expr(node, node.expr))

        cond_expr = cond_var
        if context_cond is not None:
            from pymbolic.primitives import LogicalAnd
            cond_expr = LogicalAnd((cond_var, context_cond))

            self.conditions_data.append((context_cond, cond_var))
        else:
            self.conditions_data.append((None, cond_var))

        self.conditions.append(cond_expr) 
开发者ID:inducer,项目名称:loopy,代码行数:27,代码来源:translator.py

示例4: is_interned

# 需要导入模块: from six import moves [as 别名]
# 或者: from six.moves import intern [as 别名]
def is_interned(s):
    return s is None or intern(s) is s 
开发者ID:inducer,项目名称:loopy,代码行数:4,代码来源:tools.py

示例5: intern_frozenset_of_ids

# 需要导入模块: from six import moves [as 别名]
# 或者: from six.moves import intern [as 别名]
def intern_frozenset_of_ids(fs):
    return frozenset(intern(s) for s in fs)

# vim: foldmethod=marker 
开发者ID:inducer,项目名称:loopy,代码行数:6,代码来源:tools.py

示例6: parse_special_insn

# 需要导入模块: from six import moves [as 别名]
# 或者: from six.moves import intern [as 别名]
def parse_special_insn(groups, insn_options):
    insn_options = parse_insn_options(
            insn_options.copy(),
            groups["options"],
            assignee_names=())

    del insn_options["atomicity"]

    insn_id = insn_options.pop("insn_id", None)
    inames_to_dup = insn_options.pop("inames_to_dup", [])

    kwargs = dict(
                id=(
                    intern(insn_id)
                    if isinstance(insn_id, str)
                    else insn_id),
                **insn_options)

    from loopy.kernel.instruction import NoOpInstruction, BarrierInstruction
    special_insn_kind = groups["kind"]
    # check for bad options
    check_illegal_options(insn_options, special_insn_kind)

    if special_insn_kind == "gbarrier":
        cls = BarrierInstruction
        kwargs["synchronization_kind"] = "global"
    elif special_insn_kind == "lbarrier":
        cls = BarrierInstruction
        kwargs["synchronization_kind"] = "local"
    elif special_insn_kind == "nop":
        cls = NoOpInstruction
    else:
        raise LoopyError(
            "invalid kind of special instruction: '%s'" % special_insn_kind)

    return cls(**kwargs), inames_to_dup

# }}}


# {{{ parse_instructions 
开发者ID:inducer,项目名称:loopy,代码行数:43,代码来源:creation.py

示例7: all_inames

# 需要导入模块: from six import moves [as 别名]
# 或者: from six.moves import intern [as 别名]
def all_inames(self):
        result = set()
        for dom in self.domains:
            result.update(
                    intern(n) for n in dom.get_var_names(dim_type.set))
        return frozenset(result) 
开发者ID:inducer,项目名称:loopy,代码行数:8,代码来源:__init__.py

示例8: __init__

# 需要导入模块: from six import moves [as 别名]
# 或者: from six.moves import intern [as 别名]
def __init__(self, **kwargs):
        kwargs["name"] = intern(kwargs.pop("name"))

        target = kwargs.pop("target", None)

        dtype = kwargs.pop("dtype", None)

        if 'for_atomic' in kwargs:
            for_atomic = kwargs['for_atomic']
        else:
            for_atomic = False

        from loopy.types import to_loopy_type
        dtype = to_loopy_type(
                dtype, allow_auto=True, allow_none=True, for_atomic=for_atomic,
                target=target)

        import loopy as lp
        if dtype is lp.auto:
            warn("Argument/temporary data type for '%s' should be None if "
                   "unspecified, not auto. This usage will be disallowed in 2018."
                    % kwargs["name"],
                    DeprecationWarning, stacklevel=2)

            dtype = None

        kwargs["dtype"] = dtype

        ImmutableRecord.__init__(self, **kwargs) 
开发者ID:inducer,项目名称:loopy,代码行数:31,代码来源:data.py

示例9: __setstate__

# 需要导入模块: from six import moves [as 别名]
# 或者: from six.moves import intern [as 别名]
def __setstate__(self, val):
        super(InstructionBase, self).__setstate__(val)

        from loopy.tools import intern_frozenset_of_ids

        if self.id is not None:  # pylint:disable=access-member-before-definition
            self.id = intern(self.id)
        self.depends_on = intern_frozenset_of_ids(self.depends_on)
        self.groups = intern_frozenset_of_ids(self.groups)
        self.conflicts_with_groups = (
                intern_frozenset_of_ids(self.conflicts_with_groups))
        self.within_inames = (
                intern_frozenset_of_ids(self.within_inames))

# }}} 
开发者ID:inducer,项目名称:loopy,代码行数:17,代码来源:instruction.py

示例10: intern

# 需要导入模块: from six import moves [as 别名]
# 或者: from six.moves import intern [as 别名]
def intern(self):
        """Returns either itself or a canonical copy of itself."""

        # If this is an interned object, return it
        if hasattr(self, '_interned'):
            return self._internable_stats.incr('self')

        #
        # Got to find or create an interned object identical to this
        # one. Auto-initialize the class if need be.
        #
        kls = self.__class__

        if not hasattr(kls, dict_name):
            kls._internable_init()

        obj = kls._internable_dict.get(self)
        if (obj):
            # Found an interned copy.
            kls._internable_stats.incr('found')
            return obj

        # Create an interned copy. Take care to only keep a weak
        # reference to the object itself.
        def object_collected(obj):
            kls._internable_stats.incr('collected')
            # print("Object %s garbage collected" % obj)
            pass

        ref = weakref.ref(self, object_collected)
        kls._internable_dict[self] = ref
        self._interned = True
        kls._internable_stats.incr('inserted')
        return self 
开发者ID:OpenState-SDN,项目名称:ryu,代码行数:36,代码来源:internable.py

示例11: __init__

# 需要导入模块: from six import moves [as 别名]
# 或者: from six.moves import intern [as 别名]
def __init__(self, next_attr_name=None, prev_attr_name=None):
        """Initializes this list.

        next_attr_name: The name of the attribute that holds a reference
                        to the next item in the list.

        prev_attr_name: the name of the attribute that holds a reference
                        to the previous item in the list.
        """

        # Keep an interned version of the attribute names. This should
        # speed up the process of looking up the attributes.
        self.next_name = intern(next_attr_name)
        self.prev_name = intern(prev_attr_name) 
开发者ID:OpenState-SDN,项目名称:ryu,代码行数:16,代码来源:circlist.py

示例12: __init__

# 需要导入模块: from six import moves [as 别名]
# 或者: from six.moves import intern [as 别名]
def __init__(self, size, xid, path, client, watch, server):
    self.size = size
    self.xid = xid
    self.path = intern(path)
    self.client = client
    self.server = server
    self.watch = watch
    self.timestamp = 0  # this will be set by caller later on
    self.auth = ""      # ditto 
开发者ID:twitter,项目名称:zktraffic,代码行数:11,代码来源:client_message.py

示例13: with_params

# 需要导入模块: from six import moves [as 别名]
# 或者: from six.moves import intern [as 别名]
def with_params(cls, xid, path, watch, data, offset, size, client, server):
    auth_type, offset = read_number(data, offset)
    scheme = "very-long-scheme"
    credential = "very-long-credential"

    try:
      scheme, offset = read_string(data, offset)
      credential, offset = read_string(data, offset)
    except StringTooLong: pass

    return cls(auth_type, intern(scheme), intern(credential), size, client, server) 
开发者ID:twitter,项目名称:zktraffic,代码行数:13,代码来源:client_message.py

示例14: get_path

# 需要导入模块: from six import moves [as 别名]
# 或者: from six.moves import intern [as 别名]
def get_path(self, message, suffix=None):
    if self._aggregation_depth > 0 and message.path:
      path = message.parent_path(self._aggregation_depth)
    else:
      path = message.path

    return intern(path if suffix is None else ':'.join((path, suffix))) 
开发者ID:twitter,项目名称:zktraffic,代码行数:9,代码来源:accumulators.py

示例15: __init__

# 需要导入模块: from six import moves [as 别名]
# 或者: from six.moves import intern [as 别名]
def __init__(self, max_reqs=400000, max_reps=400000, max_events=400000, timer=None):
    self._accumulators = {}
    self._cv = Condition()
    self._stopped = True
    self._requests = Deque(maxlen=max_reqs)
    self._replies = Deque(maxlen=max_reps)
    self._events = Deque(maxlen=max_events)
    self._request_handlers = set()
    self._reply_handlers = set()
    self._event_handlers = set()
    self._auth_by_client = defaultdict(lambda: intern("noauth"))
    self._timer = timer if timer else Timer()
    super(QueueStatsLoader, self).__init__()
    self.setDaemon(True) 
开发者ID:twitter,项目名称:zktraffic,代码行数:16,代码来源:loaders.py


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