本文整理汇总了Python中pypy.annotation.model.SomeObject.const方法的典型用法代码示例。如果您正苦于以下问题:Python SomeObject.const方法的具体用法?Python SomeObject.const怎么用?Python SomeObject.const使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pypy.annotation.model.SomeObject
的用法示例。
在下文中一共展示了SomeObject.const方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: union
# 需要导入模块: from pypy.annotation.model import SomeObject [as 别名]
# 或者: from pypy.annotation.model.SomeObject import const [as 别名]
def union((obj1, obj2)):
if obj1 == obj2:
return obj1
else:
result = SomeObject()
if obj1.knowntype == obj2.knowntype and obj1.knowntype != object:
result.knowntype = obj1.knowntype
is_type_of1 = getattr(obj1, 'is_type_of', None)
is_type_of2 = getattr(obj2, 'is_type_of', None)
if obj1.is_immutable_constant() and obj2.is_immutable_constant() and obj1.const == obj2.const:
result.const = obj1.const
is_type_of = {}
if is_type_of1:
for v in is_type_of1:
is_type_of[v] = True
if is_type_of2:
for v in is_type_of2:
is_type_of[v] = True
if is_type_of:
result.is_type_of = is_type_of.keys()
else:
if is_type_of1 and is_type_of1 == is_type_of2:
result.is_type_of = is_type_of1
# try to preserve the origin of SomeObjects
if obj1 == result:
result = obj1
elif obj2 == result:
result = obj2
unioncheck(result)
return result