One of our goals is to make Cython as compatible as possible with standard
One of our goals is to make Cython as compatible as possible with standard
Python. This page lists the things that work in Python but not in Cython.
Python. This page lists the things that work in Python but not in Cython.
As Cython matures, the items in this list should go away.
.. TODO: this limitation seems to be removed
.. ::
.. from module import *
.. This relies on at-runtime insertion of objects into the current namespace and
.. probably will be one of the few features never implemented (as any
.. implementation would be very slow). However, there is the --pre-import option
.. with treats all un-declared names as coming from the specified module, which
.. has the same effect as putting "from module import *" at the top-level of the
.. code. Note: the one difference is that builtins cannot be overriden in this
.. way, as the 'pre-import' scope is even higher than the builtin scope.
Nested def statements
----------------------
Function definitions (whether using ``def`` or ``cdef``) cannot be nested within
other function definitions. ::
def make_func():
def f(x):
return x*x
return f
(work in progress) This relies on functional closures
Generators
Generators
-----------
-----------
...
@@ -43,22 +20,11 @@ Generators
...
@@ -43,22 +20,11 @@ Generators
Using the yield keywords. (work in progress) This relies on functional closures
Using the yield keywords. (work in progress) This relies on functional closures
.. TODO Not really a limitation, rather an enchancement proposal
.. Support for builtin types
.. --------------------------
.. Support for statically declaring types such as list and dict and sequence
.. should be provided, and optimized code produced.
.. This needs to be well thought-out, and I think Pyrex has some plans along
.. these lines as well.
Other Current Limitations
Other Current Limitations
==========================
==========================
* The :func:`globals` and :func:`locals` functions cannot be used.
* The :func:`globals` builtin returns the last Python callers globals, not the current function's locals. This behavior should not be relied upon, as it will probably change in the future.
* The :fun:`locals` builtin can only be used if all local variables can be converted to Python objects, and returns a dict.
* Class and function definitions cannot be placed inside control structures.
* Class and function definitions cannot be placed inside control structures.
Semantic differences between Python and Cython
Semantic differences between Python and Cython
...
@@ -91,6 +57,8 @@ outside the class, and then assigning the result of ``classmethod`` or
...
@@ -91,6 +57,8 @@ outside the class, and then assigning the result of ``classmethod`` or
method = classmethod(Spam_method)
method = classmethod(Spam_method)
This will change in the near future.
.. rubric:: Footnotes
.. rubric:: Footnotes
.. [#] The reason for the different behaviour of class scopes is that
.. [#] The reason for the different behaviour of class scopes is that