Elegant way to perform tuple arithmetic

If you’re looking for fast, you can use numpy:

>>> import numpy
>>> numpy.subtract((10, 10), (4, 4))
array([6, 6])

and if you want to keep it in a tuple:

>>> tuple(numpy.subtract((10, 10), (4, 4)))
(6, 6)

Leave a Comment