vector: Implement hash cache for vector3d and vector

this gives us a small runtime improvement in the router.

For FreePDK45 word_size=8, num_words=256

Improved
*** Maze routing supplies: 89.8 seconds
** Routing: 279.3 seconds

Non-improved
*** Maze routing supplies: 105.1 seconds
** Routing: 293.5 seconds

Signed-off-by: Bastian Koppelmann <[email protected]>
This commit is contained in:
Bastian Koppelmann
2020-01-03 12:16:10 +01:00
parent 7ff5121d8c
commit c0c89e465a
2 changed files with 4 additions and 3 deletions
+2 -1
View File
@@ -28,6 +28,7 @@ class vector():
else:
self.x = float(x)
self.y = float(y)
self._hash = hash((self.x,self.y))
def __str__(self):
""" override print function output """
@@ -97,7 +98,7 @@ class vector():
Note: This assumes that you DON'T CHANGE THE VECTOR or it will
break things.
"""
return hash((self.x,self.y))
return self._hash
def snap_to_grid(self):
self.x = self.snap_offset_to_grid(self.x)