Simulating int arithmetic with wrap-around

Paul Rubin no.email at nospam.invalid
Mon Jan 2 22:22:10 EST 2017


Steve D'Aprano <steve+python at pearwood.info> writes:
> Again, assume both operands are in range for an N-bit signed integer. What's
> a good way to efficiently, or at least not too inefficiently, do the
> calculations in Python?

My first thought is towards the struct module, especially if you want to handle 
a bunch of such integers at the same time.  Or maybe the array module or some 
combination.  Or a C extension.



More information about the Python-list mailing list