From 63a5de6308640a3e6a9d928bf21fe2bf19f700e9 Mon Sep 17 00:00:00 2001 From: Robert Bradshaw Date: Wed, 10 Nov 2010 22:45:09 -0800 Subject: [PATCH] Cython limitation clarifications and updates. --- src/userguide/limitations.rst | 42 +++++------------------------------ 1 file changed, 5 insertions(+), 37 deletions(-) diff --git a/src/userguide/limitations.rst b/src/userguide/limitations.rst index 66961594..3fede2c5 100644 --- a/src/userguide/limitations.rst +++ b/src/userguide/limitations.rst @@ -11,31 +11,8 @@ Unsupported Python Features 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. +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 ----------- @@ -43,22 +20,11 @@ Generators 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 ========================== -* 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. Semantic differences between Python and Cython @@ -91,6 +57,8 @@ outside the class, and then assigning the result of ``classmethod`` or method = classmethod(Spam_method) +This will change in the near future. + .. rubric:: Footnotes .. [#] The reason for the different behaviour of class scopes is that -- 2.26.2