Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Definitely do the profiler thing but... I think the only major speedup will happen due to parallelism. Taking advantage of multiple cores is of paramount importance if you are going to run cpu bound problems like this. Try putting each line through a different (thread/process). This raises more questions of course, for example does the data need to be in the same order from the input file? if so just enumerate that and stick a second variable on the big_hairy_func for which line it will be.</p> <p>here is some boilerplate code to get started</p> <p>notes:</p> <p>xreadlines is deprecated even though it deals with large files <code>for line in file:</code> replaces it.</p> <pre><code>fi = open('1.txt') fo = open('2.txt','w') import math def log(x): return math.log(x) from math import sqrt import multiprocessing as mp import sys sys.path.append('/tools/lib/python2.7/site-packages') import scipy import numpy as np from scipy.stats.distributions import norm def big_hairy_func(linefromfile): &lt;majority of your post here&gt; return &lt;whatever data you were going to write to 'fo'&gt; if __name__ == '__main__': pool = mp.Pool(4) #rule of thumb. Replace '4' with the number of cores on your system result = pool.map(big_hairy_func, (input for input in fi.readlines())) &lt;write the result to fo that you haven't posted&gt; </code></pre> <p>xreadlines was deprecated in python 2.3 so with that version I'm not sure if the generator function will work. Let me know if you have questions about compatibility with your version of python.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload