[Python-es] (Iron)Python en Visual Studio 2008

Pablo Angulo pablo.angulo en uam.es
Mie Ene 20 18:05:17 CET 2010


¿Conocéis pyrex, y cython? Yo he usado cython para cosas muy pequeñas, y
básicamente se trata de escribir código python, pero declarando los
tipos de la variables, y recibir a cambio un aumento de velocidad que
depende drásticamente del tipo de código, pero puede llegar a 100x en
código numérico.

>
>     Is Cython faster than CPython?
>
> For most things, yes. For example, Cython can compile most of pybench
> <http://svn.python.org/projects/python/trunk/Tools/pybench/> by now,
> and runs it more than 30% faster
> <http://codespeak.net/pipermail/cython-dev/attachments/20091001/444742ad/attachment-0001.txt>
> in total, while being 60-90% faster on control structures like
> if-elif-else and for-loops.
>
> However the main advantage of Cython is that it scales very well to
> even greater performance requirements. For numerical code, speed-ups
> of 100-1000 times
> <http://thread.gmane.org/gmane.comp.python.cython.devel/4602/focus=4619>
> compared to CPython are not unusual, and are achieved by simply adding
> static type declarations to performance critical parts of the code,
> thus trading Python's dynamic typing for speed. As this can be done at
> any granularity in the code, Cython makes it easy to write simple
> Python code that is fast enough, and just tune the critical 5% of your
> code into maximum performance by using static C types in just the
> right places. 

Por supuesto, usar cython es un poco más drástico que simplemente
empaquetar el código en un ejecutable, y requiere participación del
programador.

Saludos



Más información sobre la lista de distribución Python-es