<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:

def save(diff, stream=sys.stdout, compact=False):
    "Serialize a patch object."
    flags = {'sort_keys': True}
    if not compact:
        flags['indent'] = 2

    json.dump(diff, stream, **flags)