This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author christian.heimes
Recipients Ramchandra Apte, christian.heimes, georg.brandl, pitrou, serhiy.storchaka, terry.reedy
Date 2013-10-19.10:56:52
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1382180212.29.0.284873113196.issue19251@psf.upfronthosting.co.za>
In-reply-to
Content
bytes(x ^ y for x, y in zip(a, b)) is super-slow if you have to do XOR inside a hot loop for a couple of ten thousand times. int.from_bytes + int.to_bytes is about ten times faster. I expect bitwise ops of bytes to be even faster and more readable.

$ python3.3 -m timeit -n 100000 -s "a = b'a'*64; b = b'b'*64" "bytes(x ^ y for x, y in zip(a, b))"
100000 loops, best of 3: 7.5 usec per loop

$ python3.3 -m timeit -n 100000 -s "a = b'a'*64; b = b'b'*64" "i = int.from_bytes(a, 'little') ^ int.from_bytes(b, 'little'); i.to_bytes(64, 'little')"
100000 loops, best of 3: 0.866 usec per loop
History
Date User Action Args
2013-10-19 10:56:52christian.heimessetrecipients: + christian.heimes, georg.brandl, terry.reedy, pitrou, Ramchandra Apte, serhiy.storchaka
2013-10-19 10:56:52christian.heimessetmessageid: <1382180212.29.0.284873113196.issue19251@psf.upfronthosting.co.za>
2013-10-19 10:56:52christian.heimeslinkissue19251 messages
2013-10-19 10:56:52christian.heimescreate