projects
/
python-bulletml.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
getattr3 is faster than try/except in pyrex.
[python-bulletml.git]
/
bulletml
/
_collision.pyx
diff --git
a/bulletml/_collision.pyx
b/bulletml/_collision.pyx
index
2011e98
..
b057022
100644
(file)
--- a/
bulletml/_collision.pyx
+++ b/
bulletml/_collision.pyx
@@
-28,14
+28,10
@@
def overlaps(a, b):
dx = ax - bx
dy = ay - by
dx = ax - bx
dy = ay - by
- try:
- radius = a.radius
- except AttributeError:
- radius = 0.5
- try:
- radius += b.radius
- except AttributeError:
- radius += 0.5
+
+ radius_a = getattr3(a, 'radius', 0.5)
+ radius_b = getattr3(b, 'radius', 0.5)
+ radius = radius_a + radius_b
return dx * dx + dy * dy <= radius * radius
return dx * dx + dy * dy <= radius * radius