Commit da298315 authored by Stefan Behnel's avatar Stefan Behnel

slightly extend docs on automatic type conversions

parent bd9833dc
...@@ -311,23 +311,31 @@ possibilities. ...@@ -311,23 +311,31 @@ possibilities.
+----------------------------+--------------------+------------------+ +----------------------------+--------------------+------------------+
| C types | From Python types | To Python types | | C types | From Python types | To Python types |
+============================+====================+==================+ +============================+====================+==================+
| [unsigned] char | int, long | int | | [unsigned] char, | int, long | int |
| [unsigned] short | | | | [unsigned] short, | | |
| int, long | | | | int, long | | |
+----------------------------+--------------------+------------------+ +----------------------------+--------------------+------------------+
| unsigned int | int, long | long | | unsigned int, | int, long | long |
| unsigned long | | | | unsigned long, | | |
| [unsigned] long long | | | | [unsigned] long long | | |
+----------------------------+--------------------+------------------+ +----------------------------+--------------------+------------------+
| float, double, long double | int, long, float | float | | float, double, long double | int, long, float | float |
+----------------------------+--------------------+------------------+ +----------------------------+--------------------+------------------+
| char* | str/bytes | str/bytes [#]_ | | char* | str/bytes | str/bytes [#]_ |
+----------------------------+--------------------+------------------+ +----------------------------+--------------------+------------------+
| struct | | dict | | struct, | | dict [#1]_ |
| union | | |
+----------------------------+--------------------+------------------+ +----------------------------+--------------------+------------------+
.. [#] The conversion is to/from str for Python 2.x, and bytes for Python 3.x. .. [#] The conversion is to/from str for Python 2.x, and bytes for Python 3.x.
.. [#1] The conversion from a C union type to a Python dict will add
a value for each of the union fields. Cython 0.23 and later, however,
will refuse to automatically convert a union with unsafe type
combinations. An example is a union of an ``int`` and a ``char*``,
in which case the pointer value may or be not be a valid pointer.
Caveats when using a Python string in a C context Caveats when using a Python string in a C context
------------------------------------------------- -------------------------------------------------
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment