Reading the bytes of a PDF
It's not surprising that this is too slow:
you're reading data byte-by-byte.
For faster performance you would need to read larger buffers at a time.

If you want to compare files by content, use the filecmp package.

There are also some glaring problems with this code.
For example, instead of opening a file, doing something in a try block and closing the file handle manually, you should use the recommended with-resources technique:

    with open(filename1, "rb") as f:
        b = f.read(1)
        # ...


Finally, the function name and all variable names are very poor,
and don't help the readers understand their purpose and what you're trying to do.