I have a program which needs to turn many large one-dimensional numpy arrays of floats into delimited strings. I am finding this operation quite slow relative to the mathema
Convert the numpy array into a list first. The map operation seems to run faster on a list than on a numpy array.
e.g.
import numpy as np
x = np.random.randn(100000).tolist()
for i in range(100):
",".join(map(str, x))
In timing tests I found a consistent 15% speedup for this example
I'll leave others to explain why this might be faster as I have no idea!