<br><div class="gmail_quote">On Sat, Apr 2, 2011 at 12:05 PM, John Nagle <span dir="ltr"><<a href="mailto:nagle@animats.com">nagle@animats.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<div class="im">On 4/2/2011 3:30 AM, Stefan Behnel wrote:<br>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
Cython actually supports most Python language features now (including<br>
generators in the development branch), both from Python 2 and Python 3.<br>
Chances are that the next release will actually compile most of your<br>
Python code unchanged, or only with minor adaptations.<br>
</blockquote>
<br></div>
    Cython requires the user to insert type declarations, though, to<br>
get a speed improvement.<br></blockquote><div><br>Actually, Cython often gives modest speed improvements without type declarations, and greater improvements with type declarations.  For still further improvements, you can turn to C datastructures in Cython.<br>
<br>It surprises me how often people think of Cython as a weird dialect of Python.  I know I used to before actually giving Cython a try.  Cython's really pretty close to CPython; it just has some C-like things it can do too.<br>
<br></div><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
    Shed Skin has a good type inference system, but it insists on<br>
a unique type for each object (which includes "null"; a type of<br>
"str or null" is not acceptable).  The rest of Shed Skin, outside<br>
the type inference system, is not very well developed.<br>
<br>
    There's a path there to a fast Python with some restrictions.<br>
The Shed Skin inference engine with the Cython engine might have<br>
potential.<br></blockquote><div><br>I'm not sure Shedskin and Cython are that compatible in their backends, though I imagine they could share ideas more.  ISTR that Cython already does some type inference without restricting types much.<br>
 </div><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
    PyPy gets some speedups, mostly by recognizing when numbers can be<br>
unboxed.</blockquote><div><br>For my current project, I find that Pypy gets quite remarkable speedups, even when compared to Cython:<br><br><a href="http://stromberg.dnsalias.org/~dstromberg/backshift/">http://stromberg.dnsalias.org/~dstromberg/backshift/</a> <br>
<br>The algorithm being tested is a byte-by-byte content-based checksum.<br><br>(I believe I've shared the above link here before)<br><br></div><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">

    There's no easy way to speed up Python; that's been tried.<br>
It needs either a very, very elaborate JIT system, more complex<br>
than the ones for Java or Self, or some language restrictions.<br>
The main restriction I would impose is to provide a call that says:<br>
"OK, we're done with loading, initialization, and configuration.<br>
Now freeze the code."  At that moment, all the global<br>
analysis and compiling takes place.  This allows getting rid<br>
of the GIL and getting real performance out of multithread<br>
CPUs.<font color="#888888"><br></font></blockquote><div><br>Freezing things is a nice idea - one I suggested on the unladen swallow list a while back.<br><br>But Pypy seems to be doing quite well without it, at least in my limited benchmarking.<br>
<br></div></div>