Psycho for Psyco
Psyco puede venir al pelo cuando tengamos que optimizar inner loops del backend (hablando de ONO, el comparativo de precios de Livra), ie. los que hacen number crunching o iteran estructuras de datos gargantuescas.
“But where Psyco shines is when running algorithmical code — these are the first pieces of code that you would consider rewriting in C for performance. If you are in this situation, consider using Psyco instead! You might get 10x to 100x speed-ups.”
Y usarlo es tan simple como:
import psyco # at the top of the script
psyco.full() # JIT-compiles at much as possible
O, para evitar el despilfarro de memoria:
psyco.profile() # JIT-compiles “hot spots”
O:
psyco.profile(0.3) # JIT-compiles methods that take at least 30% of the time.
O, mas discriminativamente:
psyco.bind(cpu_screwer_method)
Estos metodos candentes pueden identificarse revisando el log generado mediante:
psyco.profiler()
psyco.log()
Vale la pena probarlo antes de reimplementar en C u optimizar más inteligentemente los algoritmos.






RSS Livra Geeks