summarizer icon indicating copy to clipboard operation
summarizer copied to clipboard

Avoid redundant np.array(np.transpose(...)) – use .T instead

Open SaFE-APIOpt opened this issue 1 year ago • 0 comments

https://github.com/iamprem/summarizer/blob/373aedfee1526dfa6ebd5a4789371e9f3140c61b/lsa.py#L43 In the code: idfvector = numpy.array(numpy.transpose(idfvector)) both np.transpose() and np.array() return a NumPy array, so wrapping the result of np.transpose() in np.array() is redundant and causes unnecessary memory copying. Moreover, it's more efficient and idiomatic to use the .T shorthand for transposition: idfvector = idfvector.T This avoids redundant operations, improves readability, and performs better, especially in performance-sensitive code.

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