1
0

vec.py 487 B

1234567891011121314151617181920212223
  1. import sys
  2. is_cpython = hasattr(sys, 'getrefcount')
  3. if is_cpython:
  4. class vec2:
  5. def __init__(self, x, y):
  6. self.x = x
  7. self.y = y
  8. def __add__(self, other):
  9. return vec2(self.x + other.x, self.y + other.y)
  10. def __eq__(self, other):
  11. return self.x == other.x and self.y == other.y
  12. else:
  13. from linalg import vec2
  14. x = vec2(0, 0)
  15. for i in range(10000000):
  16. x += vec2(1, 1)
  17. assert x == vec2(10000000, 10000000)