ToJSCode method uses a very inefficient way of concatenating strings: it uses += operator. For "toy" strings this is ok, but when strings get very large, this method takes an excruciatingly long amount of time (hours) to complete. Fortunately, it is easily fixable: put all sub-strings into a list and return a join of them at the end of the function.
Python uses C-style strings: concatenating them with + operator is extremely inefficient since it takes time just to find the end of the string (\0 character) where the concatenation should take place. This is why ''.join(some_list) is much (orders of magnitude) faster than concatenating with + operator.
If possible, please implement this quick fix.
ToJSCode method uses a very inefficient way of concatenating strings: it uses += operator. For "toy" strings this is ok, but when strings get very large, this method takes an excruciatingly long amount of time (hours) to complete. Fortunately, it is easily fixable: put all sub-strings into a list and return a join of them at the end of the function.
Python uses C-style strings: concatenating them with + operator is extremely inefficient since it takes time just to find the end of the string (\0 character) where the concatenation should take place. This is why ''.join(some_list) is much (orders of magnitude) faster than concatenating with + operator.
If possible, please implement this quick fix.