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


Python W_LongObject.__init__方法代码示例

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


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

示例1: newbigint

# 需要导入模块: from pypy.objspace.std.longobject import W_LongObject [as 别名]
# 或者: from pypy.objspace.std.longobject.W_LongObject import __init__ [as 别名]
def newbigint(space, w_longtype, bigint):
    """Turn the bigint into a W_LongObject.  If withsmalllong is enabled,
    check if the bigint would fit in a smalllong, and return a
    W_SmallLongObject instead if it does.  Similar to newlong() in
    longobject.py, but takes an explicit w_longtype argument.
    """
    if (space.config.objspace.std.withsmalllong
        and space.is_w(w_longtype, space.w_long)):
        try:
            z = bigint.tolonglong()
        except OverflowError:
            pass
        else:
            from pypy.objspace.std.smalllongobject import W_SmallLongObject
            return W_SmallLongObject(z)
    from pypy.objspace.std.longobject import W_LongObject
    w_obj = space.allocate_instance(W_LongObject, w_longtype)
    W_LongObject.__init__(w_obj, bigint)
    return w_obj
开发者ID:gorakhargosh,项目名称:pypy,代码行数:21,代码来源:longtype.py

示例2: unicode_to_decimal_w

# 需要导入模块: from pypy.objspace.std.longobject import W_LongObject [as 别名]
# 或者: from pypy.objspace.std.longobject.W_LongObject import __init__ [as 别名]
            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 "
                                                "with explicit base"))
        try:
            w_value = string_to_w_long(space, s, base)
        except ParseStringError, e:
            raise OperationError(space.w_ValueError,
                                 space.wrap(e.msg))

    w_obj = space.allocate_instance(W_LongObject, w_longtype)
    W_LongObject.__init__(w_obj, w_value.num)
    return w_obj

# ____________________________________________________________

long_typedef = StdTypeDef("long",
    __doc__ = '''long(x[, base]) -> integer

Convert a string or number to a long integer, if possible.  A floating
point argument will be truncated towards zero (this does not include a
string representation of a floating point number!)  When converting a
string, use the optional base.  It is an error to supply a base when
converting a non-string.''',
    __new__ = newmethod(descr__new__),
    )
开发者ID:alkorzt,项目名称:pypy,代码行数:32,代码来源:longtype.py


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