The latter is shorter and simpler because it doesn't require importing the sys module.
One should test bigint, inf and nan to make sure all cases are covered.