title: I need to improve python function that works with loops and string how it does?
body: <p>I have such problem I have this piece of code on python2.7. It works approximately 60 seconds for object with slightly more than 70000 items in the object. How it works? It gets an object with paths to another objects and convert them to the ASCII strings. I think the problem why it is so slow is loops.</p>
  
  <pre><code>def createPath(self, path, NameOfFile ):
          temp = []
          for j in range( path.shape[0] ): 
              rr = path[j][0]
              obj = NameOfFile[rr]
              string = ''.join(chr(i) for i in obj[:])
              string = string.replace("aaaa","bbbb")      
              temp.append(string)
          return ( np.array(temp) )
  </code></pre>
  
  <p>It is not my own code, I found it in the Web  so what my question is ? How to make this piece of code faster ? I haven't huge experience in the python, but maybe there some useful libraries or tricks that may help. I appreciate all help, any ideas may be helpful.</p>