Cast lvalues to rvalue type during most comparison operations

This leads to better numeric and date comparisons, since we are comparing
actual types and not strings.
one thing i don't understand about this bit, it was not introduced by your change but before by another pull request, why the string formatting is using both .format() and the old string format methods and not just one? Maybe just using format() is less confusing. Just a micro-improvement for readability.