Addition of Python code for the main diff function