We have quite a bit of isinstance testing to sanity check parameters around the code base. For example in collision methods. These are very expensive and we should consider changeing some of the into assert or debug blocks.
# Assert with custom user message
assert isinstance(a, b), "Message to user"
# Debug block
if __debug__:
if not isinstance(a, b):
raise ValueErrror("Message to user")
Asserts and the entire __debug__ block will be purge when running python with -O option or the PYTHONOPTIMIZE environment variable is set.