return type1
# multiplication of containers/numbers with an
# integer value always (?) returns the same type
- if type1.is_int:
- return type2
- elif type2.is_int:
+ if type2.is_int:
return type1
+ elif type2.is_builtin_type and type1.is_int and self.operator == '*':
+ # multiplication of containers/numbers with an
+ # integer value always (?) returns the same type
+ return type2
return py_object_type
else:
return self.compute_c_result_type(type1, type2)
>>> builtin_type_operations()
"""
b1 = b'a' * 10
+ b1 = 10 * b'a'
assert typeof(b1) == "bytes object", typeof(b1)
b2 = b'a' + b'b'
assert typeof(b2) == "bytes object", typeof(b2)
u1 = u'a' * 10
+ u1 = 10 * u'a'
assert typeof(u1) == "unicode object", typeof(u1)
u2 = u'a' + u'b'
assert typeof(u2) == "unicode object", typeof(u2)