1 2def simple_values(obj1, obj2, obj3, obj4): 3 """ 4 >>> simple_values(True, False, 23, 'test') 5 (0.0, 1.0, False, False) 6 """ 7 cdef int bool1, bool2 8 cdef float bool3, bool4 9 cdef char *ptr1, *ptr2, *ptr0 10 cdef float f 11 bool1 = 1 12 bool2 = 0 13 ptr1 = ptr2 = NULL 14 f = 0.0 15 16 bool3 = bool1 and bool2 17 bool3 = bool1 or bool2 18 bool3 = obj1 and obj2 19 ptr0 = ptr1 and ptr2 20 bool3 = bool1 and f 21 bool4 = bool1 and bool2 and bool3 22 bool4 = bool1 or bool2 and bool3 23 obj4 = obj1 and obj2 and obj3 24 obj5 = (obj1 + obj2 + obj3) and obj4 25 return bool3, bool4, obj4, obj5 26 27 28def non_simple_values(obj1, obj2, obj3, obj4): 29 """ 30 >>> non_simple_values(1, 2, 3, 4) 31 (7, 3, 7, 3, 7, 7, 5, 5) 32 >>> non_simple_values(0, 0, 3, 4) 33 (0, 7, 4, 4, 4, 4, 4, 4) 34 >>> non_simple_values(0, 0, 1, -1) 35 (0, 0, -1, 0, -1, -1, 0, 0) 36 >>> non_simple_values(1, -1, 1, -1) 37 (0, 0, 0, 0, 0, 0, 0, 0) 38 >>> non_simple_values(1, 2, 1, -1) 39 (0, 3, 0, 3, 0, 0, 1, 1) 40 >>> non_simple_values(2, 1, 1, -1) 41 (0, 3, 1, 3, 0, 0, 1, 1) 42 """ 43 and1 = obj1 + obj2 and obj3 + obj4 44 or1 = obj1 + obj2 or obj3 + obj4 45 and_or = obj1 + obj2 and obj3 + obj4 or obj1 + obj4 46 or_and = obj1 + obj2 or obj3 + obj4 and obj1 + obj4 47 and_or_and = obj1 + obj2 and obj3 + obj4 or obj1 + obj4 and obj2 + obj4 48 and1_or_and = (and1 or (obj1 + obj4 and obj2 + obj4)) 49 or_and_or = (obj1 + obj2 or obj3 + obj4) and (obj1 + obj4 or obj2 + obj4) 50 or1_and_or = (or1 and (obj1 + obj4 or obj2 + obj4)) 51 return (and1, or1, and_or, or_and, and_or_and, and1_or_and, or_and_or, or1_and_or) 52