This answer says that the endianness of an integer in python depends on the processor architecture. Does that imply that bitwise operations like
msg = 0
msg |= 1 << n
yield a different result on different computers, depending on the processor?
A colleague recommended me to use x*2**n
instead of x << n
because the former is supposed to be platform independent. But I really don't like that because it would obfuscate my intention of setting a specific bit in a message to be sent via a can bus and might require more processing power (I don't know how much optimization the python interpreter is capable of).
Would this yield a different result (assuming that both x
and n
are positive integers)?