from pypy.interpreter.gateway import interp2app, unwrap_spec, WrappedDefault from pypy.objspace.std.stdtypedef import StdTypeDef from pypy.objspace.std.inttype import int_typedef @unwrap_spec(w_obj = WrappedDefault(False)) def descr__new__(space, w_booltype, w_obj): space.w_bool.check_user_subclass(w_booltype) if space.is_true(w_obj): return space.w_True else: return space.w_False # ____________________________________________________________ bool_typedef = StdTypeDef("bool", int_typedef, __doc__ = '''bool(x) -> bool Returns True when the argument x is true, False otherwise. The builtins True and False are the only two instances of the class bool. The class bool is a subclass of the class int, and cannot be subclassed.''', __new__ = interp2app(descr__new__), ) bool_typedef.acceptable_as_base_class = False
from pypy.interpreter import gateway from pypy.objspace.std.stdtypedef import StdTypeDef from pypy.objspace.std.inttype import int_typedef def descr__new__(space, w_booltype, w_obj=None): space.w_bool.check_user_subclass(w_booltype) if space.is_true(w_obj): return space.w_True else: return space.w_False # ____________________________________________________________ bool_typedef = StdTypeDef("bool", int_typedef, __doc__ = '''bool(x) -> bool Returns True when the argument x is true, False otherwise. The builtins True and False are the only two instances of the class bool. The class bool is a subclass of the class int, and cannot be subclassed.''', __new__ = gateway.interp2app(descr__new__), ) bool_typedef.acceptable_as_base_class = False
if space.is_true(space.gt(space.wrap(w_self.index), w_length)): w_len = space.wrap(0) w_self.w_seq = None else: w_len = space.wrap(index) if space.is_true(space.lt(w_len, space.wrap(0))): w_len = space.wrap(0) return w_len # ____________________________________________________________ iter_typedef = StdTypeDef( "sequenceiterator", __doc__='''iter(collection) -> iterator iter(callable, sentinel) -> iterator Get an iterator from an object. In the first form, the argument must supply its own iterator, or be a sequence. In the second form, the callable is called until it returns the sentinel.''', __reduce__=gateway.interp2app(descr_seqiter__reduce__), __length_hint__=gateway.interp2app(descr_seqiter__length_hint__), ) iter_typedef.acceptable_as_base_class = False reverse_iter_typedef = StdTypeDef( "reversesequenceiterator", __reduce__=gateway.interp2app(descr_reverseseqiter__reduce__), __length_hint__=gateway.interp2app(descr_reverseseqiter__length_hint__), ) reverse_iter_typedef.acceptable_as_base_class = False
""" from pypy.objspace.std.iterobject import W_ReverseSeqIterObject assert isinstance(w_self, W_ReverseSeqIterObject) from pypy.interpreter.mixedmodule import MixedModule w_mod = space.getbuiltinmodule("_pickle_support") mod = space.interp_w(MixedModule, w_mod) new_inst = mod.get("reverseseqiter_new") tup = [w_self.w_seq, space.wrap(w_self.index)] return space.newtuple([new_inst, space.newtuple(tup)]) # ____________________________________________________________ iter_typedef = StdTypeDef( "sequenceiterator", __doc__="""iter(collection) -> iterator iter(callable, sentinel) -> iterator Get an iterator from an object. In the first form, the argument must supply its own iterator, or be a sequence. In the second form, the callable is called until it returns the sentinel.""", __reduce__=gateway.interp2app(descr_seqiter__reduce__), ) iter_typedef.acceptable_as_base_class = False reverse_iter_typedef = StdTypeDef( "reversesequenceiterator", __reduce__=gateway.interp2app(descr_reverseseqiter__reduce__) ) reverse_iter_typedef.acceptable_as_base_class = False