vec.py 364 B

123456789101112131415161718
  1. import sys
  2. class vec2:
  3. def __init__(self, x, y):
  4. self.x = x
  5. self.y = y
  6. def __add__(self, other):
  7. return vec2(self.x + other.x, self.y + other.y)
  8. def __eq__(self, other):
  9. return self.x == other.x and self.y == other.y
  10. x = vec2(0, 0)
  11. for i in range(10000000):
  12. x += vec2(1, 1)
  13. assert x == vec2(10000000, 10000000)