[Python-ideas] A General Outline for Just-in-Time Acceleration of Python

David Mertz mertz at gnosis.cx
Sat Jun 14 09:30:31 CEST 2014


On Fri, Jun 13, 2014 at 11:54 PM, Joseph Martinot-Lagarde <
joseph.martinot-lagarde at m4x.org> wrote:

> Cython compiles all python, it is not restricted.
>

Well, kinda yes and no.  You are correct of course, that anything that you
can execute with 'python someprog' you can compile with 'cython someprog'.
 However, there is an obvious sense in which adding an annotation (which
is, of course, a syntax error for Python itself) "restricts" the code in
Cython.  E.g.:

   def silly():
        cdef int n, i
        for i in range(10):
            if i < 5:
                n = i + 1
            else:
                n = str(i)

This *silly* function isn't really Python code at all, of course.  But if
you ignore the annotation, it would be--pointless code, but valid. As soon
as you add the annotation, you *restrict* the type of code you can write in
the scope of the annotation.

-- 
Keeping medicines from the bloodstreams of the sick; food
from the bellies of the hungry; books from the hands of the
uneducated; technology from the underdeveloped; and putting
advocates of freedom in prisons.  Intellectual property is
to the 21st century what the slave trade was to the 16th.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20140614/94c44f62/attachment.html>


More information about the Python-ideas mailing list