Commit fe6d84c0 authored by jasongrout's avatar jasongrout Committed by Robert Bradshaw

Various doc typo and wording fixes.

parent 32ea1429
...@@ -12,7 +12,7 @@ Language Basics ...@@ -12,7 +12,7 @@ Language Basics
Cython File Types Cython File Types
================= =================
There are three file types in cython: There are three file types in Cython:
* Implementation files carry a ``.pyx`` suffix * Implementation files carry a ``.pyx`` suffix
* Definition files carry a ``.pxd`` suffix * Definition files carry a ``.pxd`` suffix
...@@ -41,7 +41,7 @@ What can it contain? ...@@ -41,7 +41,7 @@ What can it contain?
-------------------- --------------------
* Any kind of C type declaration. * Any kind of C type declaration.
* ``extern`` C function or variable decarations. * ``extern`` C function or variable declarations.
* Declarations for module implementations. * Declarations for module implementations.
* The definition parts of **extension types**. * The definition parts of **extension types**.
* All declarations of functions, etc., for an **external library** * All declarations of functions, etc., for an **external library**
...@@ -69,12 +69,12 @@ cimport ...@@ -69,12 +69,12 @@ cimport
* **cimport** does not need to be called in ``.pyx`` file for for ``.pxd`` file that has the * **cimport** does not need to be called in ``.pyx`` file for for ``.pxd`` file that has the
same name, as they are already in the same namespace. same name, as they are already in the same namespace.
* For cimport to find the stated definition file, the path to the file must be appended to the * For cimport to find the stated definition file, the path to the file must be appended to the
``-I`` option of the **cython compile command**. ``-I`` option of the **Cython compile command**.
compilation order compilation order
````````````````` `````````````````
* When a ``.pyx`` file is to be compiled, cython first checks to see if a corresponding ``.pxd`` file * When a ``.pyx`` file is to be compiled, Cython first checks to see if a corresponding ``.pxd`` file
exits and processes it first. exits and processes it first.
...@@ -92,7 +92,7 @@ How do I use it? ...@@ -92,7 +92,7 @@ How do I use it?
---------------- ----------------
* Include the ``.pxi`` file with an ``include`` statement like: ``include "spamstuff.pxi`` * Include the ``.pxi`` file with an ``include`` statement like: ``include "spamstuff.pxi``
* The ``include`` statement can appear anywhere in your cython file and at any indentation level * The ``include`` statement can appear anywhere in your Cython file and at any indentation level
* The code in the ``.pxi`` file needs to be rooted at the "zero" indentation level. * The code in the ``.pxi`` file needs to be rooted at the "zero" indentation level.
* The included code can itself contain other ``include`` statements. * The included code can itself contain other ``include`` statements.
...@@ -154,14 +154,14 @@ The ``cdef`` statement is used to make C level declarations for: ...@@ -154,14 +154,14 @@ The ``cdef`` statement is used to make C level declarations for:
soft = 2 soft = 2
runny = 3 runny = 3
:Funtions: :Functions:
:: ::
cdef int eggs(unsigned long l, float f): cdef int eggs(unsigned long l, float f):
... ...
:Extenstion Types: :Extension Types:
:: ::
...@@ -242,7 +242,7 @@ Parameters ...@@ -242,7 +242,7 @@ Parameters
* The name ``object`` can be used to explicitly declare something as a Python Object. * The name ``object`` can be used to explicitly declare something as a Python Object.
* For sake of code clarity, it recomened to always use ``object`` explicitly in your code. * For sake of code clarity, it recommended to always use ``object`` explicitly in your code.
* This is also useful for cases where the name being declared would otherwise be taken for a type:: * This is also useful for cases where the name being declared would otherwise be taken for a type::
...@@ -301,7 +301,7 @@ Keyword-only Arguments ...@@ -301,7 +301,7 @@ Keyword-only Arguments
* Shown above, the ``c``, ``d`` and ``e`` arguments can not be passed as positional arguments and must be passed as keyword arguments. * Shown above, the ``c``, ``d`` and ``e`` arguments can not be passed as positional arguments and must be passed as keyword arguments.
* Furthermore, ``c`` and ``e`` are required keyword arguments since they do not have a default value. * 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 argumrents:: * If the parameter name after the ``"*"`` is omitted, the function will not accept any extra positional arguments::
def g(a, b, *, c, d): def g(a, b, *, c, d):
... ...
...@@ -315,7 +315,7 @@ Automatic Type Conversion ...@@ -315,7 +315,7 @@ Automatic Type Conversion
* For basic numeric and string types, in most situations, when a Python object is used in the context of a C value and vice versa. * For basic numeric and string types, in most situations, when a Python object is used in the context of a C value and vice versa.
* The following table summarises the conversion possibilities, assuming ``sizeof(int) == sizeof(long)``: * The following table summarizes the conversion possibilities, assuming ``sizeof(int) == sizeof(long)``:
+----------------------------+--------------------+------------------+ +----------------------------+--------------------+------------------+
| C types | From Python types | To Python types | | C types | From Python types | To Python types |
...@@ -344,7 +344,7 @@ Automatic Type Conversion ...@@ -344,7 +344,7 @@ Automatic Type Conversion
* A Python string, passed to C context expecting a ``char*``, is only valid as long as the Python string exists. * A Python string, passed to C context expecting a ``char*``, is only valid as long as the Python string exists.
* A reference to the Python string must be kept around for as long as the C string is needed. * A reference to the Python string must be kept around for as long as the C string is needed.
* If this can't be guarenteed, then make a copy of the C string. * If this can't be guaranteed, then make a copy of the C string.
* Cython may produce an error message: ``Obtaining char* from a temporary Python value`` and will not resume compiling in situations like this:: * Cython may produce an error message: ``Obtaining char* from a temporary Python value`` and will not resume compiling in situations like this::
cdef char *s cdef char *s
...@@ -363,7 +363,7 @@ Automatic Type Conversion ...@@ -363,7 +363,7 @@ Automatic Type Conversion
s = p s = p
.. note:: .. note::
**It is up to you to be aware of this, and not to depend on Cython's error message, as it is not guarenteed to be generated for every situation.** **It is up to you to be aware of this, and not to depend on Cython's error message, as it is not guaranteed to be generated for every situation.**
Type Casting Type Casting
...@@ -379,7 +379,7 @@ Type Casting ...@@ -379,7 +379,7 @@ Type Casting
cdef char *p, float *q cdef char *p, float *q
p = <char*>q p = <char*>q
* If one of the types is a python object for ``<type>x``, Cython will try and do a coersion. * If one of the types is a python object for ``<type>x``, Cython will try and do a coercion.
.. note:: Cython will not stop a casting where there is no conversion, but it will emit a warning. .. note:: Cython will not stop a casting where there is no conversion, but it will emit a warning.
...@@ -391,11 +391,11 @@ Type Checking ...@@ -391,11 +391,11 @@ Type Checking
* A cast like ``<MyExtensionType>x`` will cast x to type ``MyExtensionType`` without type checking at all. * A cast like ``<MyExtensionType>x`` will cast x to type ``MyExtensionType`` without type checking at all.
* To have a cast type checked, use the syntax like: ``<MyExtenstionType?>x``. * To have a cast type checked, use the syntax like: ``<MyExtensionType?>x``.
* In this case, Cython will throw an error if ``"x"`` is not a (subclass) of ``MyExtenstionClass`` * In this case, Cython will throw an error if ``"x"`` is not a (subclass) of ``MyExtensionType``
* Automatic type checking for extension types can be obtained by whenever ``isinstance()`` is used as the second parameter * Automatic type checking for extension types can be obtained whenever ``isinstance()`` is used as the second parameter
Python Objects Python Objects
...@@ -463,7 +463,7 @@ Scope Rules ...@@ -463,7 +463,7 @@ Scope Rules
Built-in Constants Built-in Constants
================== ==================
Pre-defined Python built-in constants: Predefined Python built-in constants:
* None * None
* True * True
...@@ -511,13 +511,13 @@ Functions and Methods ...@@ -511,13 +511,13 @@ Functions and Methods
===================== =====================
* There are three types of function declarations in Cython as the sub-sections show below. * There are three types of function declarations in Cython as the sub-sections show below.
* Only "Python" functions can be called outside a Cython module from *Python interpretted code*. * Only "Python" functions can be called outside a Cython module from *Python interpreted code*.
Callable from Python Callable from Python
===================== =====================
* Are decalared with the ``def`` statement * Are declared with the ``def`` statement
* Are called with Python objects * Are called with Python objects
* Return Python objects * Return Python objects
* See **Parameters** for special consideration * See **Parameters** for special consideration
...@@ -613,7 +613,7 @@ Error and Exception Handling ...@@ -613,7 +613,7 @@ Error and Exception Handling
* Has no way of reporting a Python exception to it's caller. * Has no way of reporting a Python exception to it's caller.
* Will only print a warning message and the exception is ignored. * Will only print a warning message and the exception is ignored.
* Inorder to propagate exceptions like this to it's caller, you need to declare an exception value for it. * In order to propagate exceptions like this to it's caller, you need to declare an exception value for it.
* There are three forms of declaring an exception for a C compiled program. * There are three forms of declaring an exception for a C compiled program.
* First:: * First::
...@@ -631,7 +631,7 @@ Error and Exception Handling ...@@ -631,7 +631,7 @@ Error and Exception Handling
* Used when a ``-1`` may possibly be returned and is not to be considered an error. * Used when a ``-1`` may possibly be returned and is not to be considered an error.
* The ``"?"`` tells Cython that ``-1`` only indicates a *possible* error. * The ``"?"`` tells Cython that ``-1`` only indicates a *possible* error.
* Now, each time ``-1`` is returned, Cython generates a call to ``PyErr_Occurrd`` to verify it is an actual error. * Now, each time ``-1`` is returned, Cython generates a call to ``PyErr_Occurred`` to verify it is an actual error.
* Third:: * Third::
...@@ -713,7 +713,7 @@ Compile-Time Definitions ...@@ -713,7 +713,7 @@ Compile-Time Definitions
* Names defined by other ``DEF`` statements * Names defined by other ``DEF`` statements
* They can be combined using any of the Python expression syntax * They can be combined using any of the Python expression syntax
* Cython provides the following pre-defined names * Cython provides the following predefined names
* Corresponding to the values returned by ``os.uname()`` * Corresponding to the values returned by ``os.uname()``
...@@ -726,7 +726,7 @@ Compile-Time Definitions ...@@ -726,7 +726,7 @@ Compile-Time Definitions
* A name defined by ``DEF`` can appear anywhere an identifier can appear. * A name defined by ``DEF`` can appear anywhere an identifier can appear.
* Cython replaces the name with the literal value before compilation. * Cython replaces the name with the literal value before compilation.
* The compile-time expression, in this case, must eveluate to a Python value of ``int``, ``long``, ``float``, or ``str``:: * The compile-time expression, in this case, must evaluate to a Python value of ``int``, ``long``, ``float``, or ``str``::
cdef int a1[ArraySize] cdef int a1[ArraySize]
cdef int a2[OtherArraySize] cdef int a2[OtherArraySize]
...@@ -736,8 +736,8 @@ Compile-Time Definitions ...@@ -736,8 +736,8 @@ Compile-Time Definitions
Conditional Statements Conditional Statements
======================= =======================
* Similiar semantics of the C pre-processor * Similar semantics of the C pre-processor
* The following statements can be used to conditinally include or exclude sections of code to compile. * The following statements can be used to conditionally include or exclude sections of code to compile.
* ``IF`` * ``IF``
* ``ELIF`` * ``ELIF``
......
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