Tim Peters wrote:
i = -2147483648
OverflowError: integer literal too large
i = -2147483648L int(i) # it *is* a valid integer literal
Python's grammar is such that negative integer literals don't exist; what you actually have there is the unary minus operator applied to positive integer literals; indeed,
Well, knowing that there are more negatives than positives and then coding it this way appears in fact as a design flaw to me.
A simple solution could be to do the opposite: Always store a negative number and negate it for positive numbers. A real negative number would then end up with two UNARY_NEGATIVE opcodes in sequence. If we had a simple postprocessor to remove such sequences at the end, we're done. As another step, it could also adjust all such consts and remove those opcodes.
This could be a task for Skip's peephole optimizer. Why did it never go into the core?
ciao - chris