PDA

View Full Version : [SOLVED] About CPU optimization ?



prismctg
August 25th, 2012, 01:13 PM
How can i do "CPU optimization" in python ? actually i haven't any concept about doing this kind of staff :(

MadCow108
August 25th, 2012, 02:14 PM
what do you mean cpu optimizations?
optimizing your python program for certain cpu types?

you can't really do that directly in python, as it is running a sort of virtual machine not the real cpu. The virtual machine does the low level cpu stuff for you.

you can write inline C/C++ code with various libraries like scipy.weave which would allow this though.

But the better way is to use appropriate modules which do the cpu type optimizations for you, like numpy or write your own C/C++ extension module in a similar way.

Another option is using pypy which compiles to machine code just in time.
But it optimizations using modern simd cpu instructions is still in a pretty early stage there.