You should use `tempnam` when available, it must be more performant than your implementation.