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


Python StdTypeDef.custom_hash方法代码示例

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


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

示例1: SMM

# 需要导入模块: from pypy.objspace.std.stdtypedef import StdTypeDef [as 别名]
# 或者: from pypy.objspace.std.stdtypedef.StdTypeDef import custom_hash [as 别名]
                                          ' one of the sets.)')
frozenset_union                 = SMM('union', 2,
                                      doc='Return the union of two sets as a'
                                          ' new set.\n\n(i.e. all elements'
                                          ' that are in either set.)')
frozenset_reduce                = SMM('__reduce__',1,
                                      doc='Return state information for'
                                          ' pickling.')

register_all(vars(), globals())

def descr__frozenset__new__(space, w_frozensettype, w_iterable=NoneNotWrapped):
    from pypy.objspace.std.setobject import W_FrozensetObject
    from pypy.objspace.std.setobject import _is_frozenset_exact
    if _is_frozenset_exact(w_iterable):
        return w_iterable
    w_obj = space.allocate_instance(W_FrozensetObject, w_frozensettype)
    W_FrozensetObject.__init__(w_obj, space, None)

    return w_obj

frozenset_typedef = StdTypeDef("frozenset",
    __doc__ = """frozenset(iterable) --> frozenset object

Build an immutable unordered collection.""",
    __new__ = newmethod(descr__frozenset__new__),
    )

frozenset_typedef.custom_hash = True
frozenset_typedef.registermethods(globals())
开发者ID:TheDunn,项目名称:flex-pypy,代码行数:32,代码来源:frozensettype.py

示例2: complexwprop

# 需要导入模块: from pypy.objspace.std.stdtypedef import StdTypeDef [as 别名]
# 或者: from pypy.objspace.std.stdtypedef.StdTypeDef import custom_hash [as 别名]
    W_ComplexObject.__init__(w_obj, realval, imagval)
    return w_obj

def complexwprop(name):
    def fget(space, w_obj):
        from pypy.objspace.std.complexobject import W_ComplexObject
        if not isinstance(w_obj, W_ComplexObject):
            raise OperationError(space.w_TypeError,
                                 space.wrap("descriptor is for 'complex'"))
        return space.newfloat(getattr(w_obj, name))
    return GetSetProperty(fget)
    
def descr___getnewargs__(space,  w_self):
    from pypy.objspace.std.complexobject import W_ComplexObject
    assert isinstance(w_self, W_ComplexObject)
    return space.newtuple([space.newcomplex(w_self.realval,w_self.imagval)]) 
    
complex_typedef = StdTypeDef("complex",
    __doc__ = """complex(real[, imag]) -> complex number
        
Create a complex number from a real part and an optional imaginary part.
This is equivalent to (real + imag*1j) where imag defaults to 0.""",
    __new__ = newmethod(descr__new__),
    __getnewargs__ = newmethod(descr___getnewargs__),
    real = complexwprop('realval'),
    imag = complexwprop('imagval'),
    )

complex_typedef.custom_hash = True
complex_typedef.registermethods(globals())
开发者ID:AishwaryaKM,项目名称:python-tutorial,代码行数:32,代码来源:complextype.py


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