Для всего, кроме регионов, вы можете использовать numpy . Примерно так (не проверено):
import numpy as np
a = np.fromfile("file A", dtype="uint8")
b = np.fromfile("file B", dtype="uint8")
# Compute the number of bytes that are different
different_bytes = np.sum(a != b)
# Compute the sum of the differences
difference = np.sum(a - b)
# Compute the sum of the absolute value of the differences
absolute_difference = np.sum(np.abs(a - b))
# In some cases, the number of bits that have changed is a better
# measurement of change. To compute it we make a lookup array where
# bitcount_lookup[byte] == number_of_1_bits_in_byte (so
# bitcount_lookup[0:16] == [0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4])
bitcount_lookup = np.array(
[bin(i).count("1") for i in range(256)], dtype="uint8")
# Numpy allows using an array as an index. ^ computes the XOR of
# each pair of bytes. The result is a byte with a 1 bit where the
# bits of the input differed, and a 0 bit otherwise.
bit_diff_count = np.sum(bitcount_lookup[a ^ b])
Я не смог найти единую функцию для вычисления регионов, но просто напишите свою собственную, используя a != b
в качестве ввода, это не должно быть сложно. См. этот вопрос для вдохновения.