Removing the call to __str__ speeds up the following example
(admittedly slightly aritificial) by ~5%, with no disadvantage
(exceptions will automatically call repr on their argument if a
traceback actually needs to be displayed):
from poly_point_isect import *
import random
from timeit import Timer
random.seed(1)
points = [(random.random(), random.random()) for _ in range(200)]
n, t = Timer("isect_polygon(points)", globals=globals()).autorange()
print(t/n)
Removing the call to
__str__
speeds up the following example (admittedly slightly aritificial) by ~5%, with no disadvantage (exceptions will automatically callrepr
on their argument if a traceback actually needs to be displayed):