本文整理汇总了Python中pypy.objspace.std.longobject.W_LongObject.fromint方法的典型用法代码示例。如果您正苦于以下问题:Python W_LongObject.fromint方法的具体用法?Python W_LongObject.fromint怎么用?Python W_LongObject.fromint使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pypy.objspace.std.longobject.W_LongObject
的用法示例。
在下文中一共展示了W_LongObject.fromint方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: pow_ovr
# 需要导入模块: from pypy.objspace.std.longobject import W_LongObject [as 别名]
# 或者: from pypy.objspace.std.longobject.W_LongObject import fromint [as 别名]
def pow_ovr(space, w_int1, w_int2):
try:
return _impl_pow(space, r_longlong(w_int1.intval), w_int2)
except FailedToImplementArgs:
from pypy.objspace.std import longobject
w_a = W_LongObject.fromint(space, w_int1.intval)
w_b = W_LongObject.fromint(space, w_int2.intval)
return longobject.pow__Long_Long_None(space, w_a, w_b, space.w_None)
示例2: lshift_ovr
# 需要导入模块: from pypy.objspace.std.longobject import W_LongObject [as 别名]
# 或者: from pypy.objspace.std.longobject.W_LongObject import fromint [as 别名]
def lshift_ovr(space, w_int1, w_int2):
a = r_longlong(w_int1.intval)
try:
return lshift__SmallLong_Int(space, W_SmallLongObject(a), w_int2)
except FailedToImplementArgs:
from pypy.objspace.std import longobject
w_a = W_LongObject.fromint(space, w_int1.intval)
w_b = W_LongObject.fromint(space, w_int2.intval)
return longobject.lshift__Long_Long(space, w_a, w_b)
示例3: _pow_ovf2long
# 需要导入模块: from pypy.objspace.std.longobject import W_LongObject [as 别名]
# 或者: from pypy.objspace.std.longobject.W_LongObject import fromint [as 别名]
def _pow_ovf2long(space, iv, iw, w_modulus):
if space.is_none(w_modulus) and _recover_with_smalllong(space):
from pypy.objspace.std.smalllongobject import _pow as _pow_small
try:
# XXX: shouldn't have to pass r_longlong(0) here (see
# 4fa4c6b93a84)
return _pow_small(space, r_longlong(iv), iw, r_longlong(0))
except (OverflowError, ValueError):
pass
from pypy.objspace.std.longobject import W_LongObject
w_iv = W_LongObject.fromint(space, iv)
w_iw = W_LongObject.fromint(space, iw)
return w_iv.descr_pow(space, w_iw, w_modulus)
示例4: ovf2long
# 需要导入模块: from pypy.objspace.std.longobject import W_LongObject [as 别名]
# 或者: from pypy.objspace.std.longobject.W_LongObject import fromint [as 别名]
def ovf2long(space, x, y):
"""Handle overflowing to smalllong or long"""
if _recover_with_smalllong(space):
if ovf2small:
return ovf2small(space, x, y)
# Assume a generic operation without an explicit ovf2small
# handler
from pypy.objspace.std.smalllongobject import W_SmallLongObject
a = r_longlong(x)
b = r_longlong(y)
return W_SmallLongObject(op(a, b))
from pypy.objspace.std.longobject import W_LongObject
w_x = W_LongObject.fromint(space, x)
w_y = W_LongObject.fromint(space, y)
return getattr(w_x, 'descr_' + opname)(space, w_y)
示例5: OperationError
# 需要导入模块: from pypy.objspace.std.longobject import W_LongObject [as 别名]
# 或者: from pypy.objspace.std.longobject.W_LongObject import fromint [as 别名]
except ParseStringError, e:
raise OperationError(space.w_ValueError,
space.wrap(e.msg))
else:
# otherwise, use the __long__() method
w_obj = space.long(w_value)
# 'long(x)' should return whatever x.__long__() returned
if space.is_w(w_longtype, space.w_long):
return w_obj
if space.is_true(space.isinstance(w_obj, space.w_long)):
assert isinstance(w_obj, W_LongObject) # XXX this could fail!
# XXX find a way to do that even if w_obj is not a W_LongObject
w_value = w_obj
elif space.is_true(space.isinstance(w_obj, space.w_int)):
intval = space.int_w(w_obj)
w_value = W_LongObject.fromint(space, intval)
else:
raise OperationError(space.w_ValueError,
space.wrap("value can't be converted to long"))
else:
base = space.int_w(w_base)
if space.is_true(space.isinstance(w_value, space.w_unicode)):
from pypy.objspace.std.unicodeobject import unicode_to_decimal_w
s = unicode_to_decimal_w(space, w_value)
else:
try:
s = space.str_w(w_value)
except OperationError, e:
raise OperationError(space.w_TypeError,
space.wrap("long() can't convert non-string "
示例6: newlong
# 需要导入模块: from pypy.objspace.std.longobject import W_LongObject [as 别名]
# 或者: from pypy.objspace.std.longobject.W_LongObject import fromint [as 别名]
def newlong(self, val): # val is an int
if self.config.objspace.std.withsmalllong:
from pypy.objspace.std.smalllongobject import W_SmallLongObject
return W_SmallLongObject.fromint(val)
return W_LongObject.fromint(self, val)
示例7: descr_long
# 需要导入模块: from pypy.objspace.std.longobject import W_LongObject [as 别名]
# 或者: from pypy.objspace.std.longobject.W_LongObject import fromint [as 别名]
def descr_long(self, space):
# XXX: should try smalllong
from pypy.objspace.std.longobject import W_LongObject
return W_LongObject.fromint(space, self.intval)