本文整理匯總了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()
示例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
示例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)
示例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
示例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
示例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
示例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)
示例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)
示例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))
# }}}
示例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
示例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)
示例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
示例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)
示例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)))
示例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)