You seem to assume that Python internally stores integers as strings of decimal digits. That is completely false. Integers, even arbitrary precision ones (long
in 3.x), are stored as bit strings. XORing two Python integers simply performs the native XOR operation on the bits as stored in memory. It loads 2x 64 bits from memory into registers, XORs the bits as efficiently as the CPU allows, and writes the result back to memory. No conversion necessary.
To be completely honest, it does not use some of those 64 bits (this is used for easier overflow detection in multiplication), but it does that by just leaving those bits as zeroes all the time.