ParticleOverdose icon indicating copy to clipboard operation
ParticleOverdose copied to clipboard

Remove unnecessary numpy.array() conversion after numpy.dot()

Open SaFE-APIOpt opened this issue 8 months ago • 1 comments

https://github.com/yolowex/ParticleOverdose/blob/7d5a1e474794b313550de5cee9a9e8cf2630e926/pt.py#L16 In the line: return numpy.array(res).reshape(8) the use of numpy.array(res) is unnecessary because numpy.dot() already returns a NumPy ndarray. Wrapping it again with numpy.array() introduces redundant copying, leading to unnecessary memory and performance overhead. The code can be simplified and made more efficient by directly calling .reshape() on the result: return res.reshape(8)

This change preserves the functionality while avoiding an extra and unnecessary array copy.

SaFE-APIOpt avatar Mar 18 '25 02:03 SaFE-APIOpt

Thanks, make a pr so i'll accept it

yolowex avatar Apr 28 '25 09:04 yolowex