-
- Downloads
Implement __bool__ and __len__ via unary_op virtual method for all types.
__bool__() and __len__() are just the same as __neg__() or __invert__(), and require efficient dispatching implementation (not requiring search/lookup). type->unary_op() is just the right choice for this short of adding standalone virtual method(s) to already big mp_obj_type_t structure.
Showing
- py/obj.c 8 additions, 2 deletionspy/obj.c
- py/objarray.c 10 additions, 0 deletionspy/objarray.c
- py/objbool.c 1 addition, 1 deletionpy/objbool.c
- py/objcomplex.c 1 addition, 1 deletionpy/objcomplex.c
- py/objdict.c 2 additions, 1 deletionpy/objdict.c
- py/objfloat.c 1 addition, 1 deletionpy/objfloat.c
- py/objint_longlong.c 1 addition, 1 deletionpy/objint_longlong.c
- py/objlist.c 2 additions, 1 deletionpy/objlist.c
- py/objnone.c 1 addition, 1 deletionpy/objnone.c
- py/objtuple.c 2 additions, 1 deletionpy/objtuple.c
- py/runtime.c 10 additions, 5 deletionspy/runtime.c
- py/runtime0.h 4 additions, 1 deletionpy/runtime0.h
- tests/basics/true-value.py 9 additions, 0 deletionstests/basics/true-value.py
Loading
Please register or sign in to comment