optimization - How to speed up simple loop in python -


i want accelerate speed of loop in python. there code below.

for x in dpath.util.search(self.data, "**", yielded=true):         self.contentslist.append(x) 

dpath.util.search generator. how speed simple loop??

well, loop unnecessary; let python looping & append work single function call instead of many calls with:

self.contentslist.extend(dpath.util.search(self.data, "**", yielded=true)) 

Comments

Popular posts from this blog

mysql - Dreamhost PyCharm Django Python 3 Launching a Site -

java - Sending SMS with SMSLib and Web Services -

java - How to resolve The method toString() in the type Object is not applicable for the arguments (InputStream) -