warm start and some perf

This commit is contained in:
Jan Petykiewicz 2026-03-20 16:59:36 -07:00
commit f505694523

View file

@ -25,10 +25,20 @@ class Port:
x: float,
y: float,
orientation: float,
snap: bool = True
) -> None:
self.x = snap_nm(x)
self.y = snap_nm(y)
self.orientation = float(orientation % 360)
if snap:
self.x = round(x * 1000) / 1000
self.y = round(y * 1000) / 1000
# Faster orientation normalization for common cases
if 0 <= orientation < 360:
self.orientation = float(orientation)
else:
self.orientation = float(orientation % 360)
else:
self.x = x
self.y = y
self.orientation = float(orientation)
def __repr__(self) -> str:
return f'Port(x={self.x}, y={self.y}, orientation={self.orientation})'