Say you have a 32 bit integer, why not just move A into the first 16 bit half and B into the other?
def vec_pack(vec): return vec[0] + vec[1] * 65536; def vec_unpack(number): return [number % 65536, int(number // 65536)];65536]; Other than this being as space efficient as possible and cheap to compute, a really cool side effect is that you can do vector math on the packed number.
a = vec_pack([2,4]) b = vec_pack([1,2]) print(vec_unpack(a+b)) # [3, 6] Vector addition print(vec_unpack(a-b)) # [1, 2] Vector subtraction print(vec_unpack(a*2)) # [4, 8] VectorScalar multiplication that goes through these two points