python - How to use scipy weave and sscanf to parse string to numpy array? -


i'm working on scientific python code speed up. 1 specific problem reading in lots data stored in text files using formated strings. figured out approach using split() , np.array() works nicely, slow if compared i'm used fortran.

i'm wondering weather scipy.weave used here, unfortunately i'm no expert in c. here example:

line ="  0.7711408e-01  0.7616138e-01  0.7521919e-01" arr = np.array(line.split(),dtype=np.float) print arr 

this works, far slow large data sets. this, bu working?

line ="  0.7711408e-01  0.7616138e-01  0.7521919e-01" arr = np.zeros(3) weave.inline("""sscanf(std::string(line).c_str(),"%f %f %f",arr);""",['line','arr']) print arr 


Comments

Popular posts from this blog

Detect support for Shoutcast ICY MP3 without navigator.userAgent in Firefox? -

web - SVG not rendering properly in Firefox -

java - JavaFX 2 slider labelFormatter not being used -