Skip to content

Commit 1be9da6

Browse files
committed
facets_area speedup
1 parent e877ee2 commit 1be9da6

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

trimesh/base.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1562,7 +1562,11 @@ def facets_area(self):
15621562
# avoid thrashing the cache inside a loop
15631563
area_faces = self.area_faces
15641564
# sum the area of each group of faces represented by facets
1565-
areas = np.array([area_faces[i].sum() for i in self.facets])
1565+
# use native python sum in tight loop as opposed to array.sum()
1566+
# as in this case the lower function call overhead of
1567+
# native sum provides roughly a 50% speedup
1568+
areas = np.array([sum(area_faces[i]) for i in self.facets],
1569+
dtype=np.float64)
15661570
return areas
15671571

15681572
@caching.cache_decorator

trimesh/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = '2.33.40'
1+
__version__ = '2.33.41'

0 commit comments

Comments
 (0)