In python, if we give a = 2 * 4, then "a" will be of integer type. But if we give a = 2 ** 400, then "a" will automatically have a long type, which is java BigInteger.
That way, Python can automatically convert an integer to BigInteger when necessary. My question is: if every time it performs an arithmetic operation on an integer, Python checks to see if this operation causes an overflow or not. If overflow, translate it to BigInteger. Wouldn't that be expensive? Since this basically means that Python inserts an overflow check statement after each integer arithmetic instruction. So how can python naturally support a large integer and be efficient?
source
share