C functions, on the other hand, can have parameters of any type, since they're
passed in directly using a normal C function call.
+A more complete comparison of the pros and cons of these different method
+types can be found at :ref:`early-binding-for-speed`.
+
Python objects as parameters and return values
----------------------------------------------
separate parts that may be more appropriate in many cases. See
:ref:`sharing-declarations`.
-Keyword-only arguments
-======================
-
-Python functions can have keyword-only arguments listed after the ``*``
-parameter and before the ``**`` parameter if any, e.g.::
-
- def f(a, b, *args, c, d = 42, e, **kwds):
- ...
-
-Here ``c``, ``d`` and ``e`` cannot be passed as position arguments and must be
-passed as keyword arguments. Furthermore, ``c`` and ``e`` are required keyword
-arguments, since they do not have a default value.
-
-If the parameter name after the ``*`` is omitted, the function will not accept any
-extra positional arguments, e.g.::
-
- def g(a, b, *, c, d):
- ...
-
-takes exactly two positional parameters and has two required keyword parameters.
-
Conditional Compilation
=======================
.. This needs to be well thought-out, and I think Pyrex has some plans along
.. these lines as well.
-Modulo '%' operation on floats
--------------------------------
-::
-
- a = b%c
-
-where `b` and `c` are floats will raise the error "Invalid operand types for '%' (float; float)"
-
-This can currently be worked around by putting::
-
- cdef extern from "math.h":
- double fmod(double x, double y)
-
-somewhere is the source file and then using::
-
- a = fmod(b,c)
-
Other Current Limitations
==========================
Differences between Cython and Pyrex
**************************************
+.. warning::
+ Both Cython and Pyrex are moving targets. It has come to the point
+ that an explicit list of all the differences between the two
+ projects would be laborious to list and track, but hopefully
+ this high-level list gives an idea of the differences that
+ are present. It should be noted that both projects make an effort
+ at mutual compatibility, but Cython's goal is to be as close to
+ and complete as Python as reasonable.
+
+
+Python 3.0 Support
+==================
+
+Cython creates ``.c`` files that can be built and used with both
+Python 2.x and Python 3.x. In fact, compiling your module with
+Cython may very well be the easiest way to port code to Python 3.0.
+We are also working to make the compiler run in both Python 2.x and 3.0.
+
+Many Python 3 constructs are already supported by Cython.
+
List/Set/Dict Comprehensions
-=============================
+----------------------------
Cython supports the different comprehensions defined by Python 3.0 for
lists, sets and dicts::
Note that Cython also supports set literals starting from Python 2.3.
+Keyword-only arguments
+----------------------
+
+Python functions can have keyword-only arguments listed after the ``*``
+parameter and before the ``**`` parameter if any, e.g.::
+
+ def f(a, b, *args, c, d = 42, e, **kwds):
+ ...
+
+Here ``c``, ``d`` and ``e`` cannot be passed as position arguments and must be
+passed as keyword arguments. Furthermore, ``c`` and ``e`` are required keyword
+arguments, since they do not have a default value.
+
+If the parameter name after the ``*`` is omitted, the function will not accept any
+extra positional arguments, e.g.::
+
+ def g(a, b, *, c, d):
+ ...
+
+takes exactly two positional parameters and has two required keyword parameters.
+
+
Conditional expressions "x if b else y" (python 2.5)
=====================================================
``True`` or ``False`` then no method call is made.)
Executable class bodies
-=========================
+=======================
Including a working :func:`classmethod`::
Cython emits a (non-spoofable and faster) typecheck whenever
:func:`isinstance` is used with an extension type as the second parameter.
+From __future__ directives
+==========================
+
+Cython supports several from __future__ directives, namely ``unicode_literals`` and ``division``.
+
+With statements are always enabled.
+
+Pure Python mode
+================
+
+Cython has support for compiling ``.py`` files, and
+accepting type annotations using decorators and other
+valid Python syntax. This allows the same source to
+be interpreted as straight Python, or compiled for
+optimized results.
+See http://wiki.cython.org/pure
+for more details.
+