mirror of
https://github.com/pocketpy/pocketpy
synced 2025-10-20 03:20:18 +00:00
Create vec.py
This commit is contained in:
parent
845c9153e8
commit
68c8f72ba5
23
benchmarks/vec.py
Normal file
23
benchmarks/vec.py
Normal file
@ -0,0 +1,23 @@
|
||||
import sys
|
||||
|
||||
is_cpython = hasattr(sys, 'getrefcount')
|
||||
|
||||
if is_cpython:
|
||||
class vec2:
|
||||
def __init__(self, x, y):
|
||||
self.x = x
|
||||
self.y = y
|
||||
|
||||
def __add__(self, other):
|
||||
return vec2(self.x + other.x, self.y + other.y)
|
||||
|
||||
def __eq__(self, other):
|
||||
return self.x == other.x and self.y == other.y
|
||||
else:
|
||||
from linalg import vec2
|
||||
|
||||
x = vec2(0, 0)
|
||||
for i in range(10000000):
|
||||
x += vec2(1, 1)
|
||||
|
||||
assert x == vec2(5000000, 5000000)
|
Loading…
x
Reference in New Issue
Block a user