Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Gwenaël Samain
cython
Commits
bd2a3d43
Commit
bd2a3d43
authored
Sep 27, 2008
by
ggellner@encolpuis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Made cython highlighting the default in all files.
parent
e5d24fd8
Changes
12
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
44 additions
and
22 deletions
+44
-22
docs/early_binding_for_speed.rst
docs/early_binding_for_speed.rst
+12
-4
docs/extension_types.rst
docs/extension_types.rst
+3
-2
docs/external_C_code.rst
docs/external_C_code.rst
+2
-0
docs/language_basics.rst
docs/language_basics.rst
+2
-0
docs/limitations.rst
docs/limitations.rst
+2
-0
docs/numpy_tutorial.rst
docs/numpy_tutorial.rst
+7
-15
docs/overview.rst
docs/overview.rst
+2
-0
docs/pyrex_differences.rst
docs/pyrex_differences.rst
+2
-0
docs/sharing_declarations.rst
docs/sharing_declarations.rst
+2
-0
docs/source_files_and_compilation.rst
docs/source_files_and_compilation.rst
+2
-0
docs/tutorial.rst
docs/tutorial.rst
+6
-1
docs/wrapping_CPlusPlus.rst
docs/wrapping_CPlusPlus.rst
+2
-0
No files found.
docs/early_binding_for_speed.rst
View file @
bd2a3d43
.. highlight:: cython
.. _early-binding-speed-label:
.. _early-binding-speed-label:
Early Binding for Speed
Early Binding for Speed
...
@@ -17,7 +19,9 @@ slowness compared to 'early binding' languages such as C++.
...
@@ -17,7 +19,9 @@ slowness compared to 'early binding' languages such as C++.
However with Cython it is possible to gain significant speed-ups through the
However with Cython it is possible to gain significant speed-ups through the
use of 'early binding' programming techniques.
use of 'early binding' programming techniques.
For example, consider the following (silly) code example::
For example, consider the following (silly) code example:
.. sourcecode:: cython
cdef class Rectangle:
cdef class Rectangle:
cdef int x0, y0
cdef int x0, y0
...
@@ -38,7 +42,9 @@ In the :func:`rectArea` method, the call to :meth:`rect.area` and the
...
@@ -38,7 +42,9 @@ In the :func:`rectArea` method, the call to :meth:`rect.area` and the
:meth:`.area` method contain a lot of Python overhead.
:meth:`.area` method contain a lot of Python overhead.
However, in Cython, it is possible to eliminate a lot of this overhead in cases
However, in Cython, it is possible to eliminate a lot of this overhead in cases
where calls occur within Cython code. For example::
where calls occur within Cython code. For example:
.. sourcecode:: cython
cdef class Rectangle:
cdef class Rectangle:
cdef int x0, y0
cdef int x0, y0
...
@@ -71,7 +77,9 @@ Rectangle. By using this declaration, instead of just dynamically assigning to
...
@@ -71,7 +77,9 @@ Rectangle. By using this declaration, instead of just dynamically assigning to
But Cython offers us more simplicity again, by allowing us to declare
But Cython offers us more simplicity again, by allowing us to declare
dual-access methods - methods that can be efficiently called at C level, but
dual-access methods - methods that can be efficiently called at C level, but
can also be accessed from pure Python code at the cost of the Python access
can also be accessed from pure Python code at the cost of the Python access
overheads. Consider this code::
overheads. Consider this code:
.. sourcecode:: cython
cdef class Rectangle:
cdef class Rectangle:
cdef int x0, y0
cdef int x0, y0
...
@@ -90,7 +98,7 @@ overheads. Consider this code::
...
@@ -90,7 +98,7 @@ overheads. Consider this code::
rect = Rectangle(x0, y0, x1, y1)
rect = Rectangle(x0, y0, x1, y1)
return rect.area()
return rect.area()
..
n
ote::
..
N
ote::
in earlier versions of Cython, the :keyword:`cpdef` keyword is
in earlier versions of Cython, the :keyword:`cpdef` keyword is
:keyword:`rdef` - but has the same effect).
:keyword:`rdef` - but has the same effect).
...
...
docs/extension_types.rst
View file @
bd2a3d43
.. highlight:: cython
Extension Types
Extension Types
===============
===============
Introduction
Introduction
------------
------------
-
As well as creating normal user-defined classes with the Python class
As well as creating normal user-defined classes with the Python class
statement, Cython also lets you create new built-in Python types, known as
statement, Cython also lets you create new built-in Python types, known as
...
@@ -34,7 +35,7 @@ extension types to wrap arbitrary C data structures and provide a Python-like
...
@@ -34,7 +35,7 @@ extension types to wrap arbitrary C data structures and provide a Python-like
interface to them.
interface to them.
Attributes
Attributes
----------
----------
-
Attributes of an extension type are stored directly in the object's C struct.
Attributes of an extension type are stored directly in the object's C struct.
The set of attributes is fixed at compile time; you can't add attributes to an
The set of attributes is fixed at compile time; you can't add attributes to an
...
...
docs/external_C_code.rst
View file @
bd2a3d43
.. highlight:: cython
Interfacing with External C Code
Interfacing with External C Code
================================
================================
...
...
docs/language_basics.rst
View file @
bd2a3d43
.. highlight:: cython
.. _language-basics-label:
.. _language-basics-label:
Language Basics
Language Basics
...
...
docs/limitations.rst
View file @
bd2a3d43
.. highlight:: cython
.. _cython-limitations-label:
.. _cython-limitations-label:
*************
*************
...
...
docs/numpy_tutorial.rst
View file @
bd2a3d43
.. highlight:: cython
.. _numpy_tute-label:
.. _numpy_tute-label:
**************************
**************************
...
@@ -220,9 +222,7 @@ Adding types
...
@@ -220,9 +222,7 @@ Adding types
=============
=============
To add types we use custom Cython syntax, so we are now breaking Python source
To add types we use custom Cython syntax, so we are now breaking Python source
compatibility. Here's :file:`convolve2.pyx`. *Read the comments!*
compatibility. Here's :file:`convolve2.pyx`. *Read the comments!* ::
.. code-block:: cython
from __future__ import division
from __future__ import division
import numpy as np
import numpy as np
...
@@ -339,9 +339,7 @@ not provided then one-dimensional is assumed).
...
@@ -339,9 +339,7 @@ not provided then one-dimensional is assumed).
More information on this syntax [:enhancements/buffer:can be found here].
More information on this syntax [:enhancements/buffer:can be found here].
Showing the changes needed to produce :file:`convolve3.pyx` only:
Showing the changes needed to produce :file:`convolve3.pyx` only::
.. sourcecode:: cython
...
...
def naive_convolve(np.ndarray[DTYPE_t, ndim=2] f, np.ndarray[DTYPE_t, ndim=2] g):
def naive_convolve(np.ndarray[DTYPE_t, ndim=2] f, np.ndarray[DTYPE_t, ndim=2] g):
...
@@ -374,9 +372,7 @@ The array lookups are still slowed down by two factors:
...
@@ -374,9 +372,7 @@ The array lookups are still slowed down by two factors:
2. Negative indices are checked for and handled correctly. The code above is
2. Negative indices are checked for and handled correctly. The code above is
explicitly coded so that it doesn't use negative indices, and it
explicitly coded so that it doesn't use negative indices, and it
(hopefully) always access within bounds. We can add a decorator to disable
(hopefully) always access within bounds. We can add a decorator to disable
bounds checking:
bounds checking::
.. sourcecode:: cython
...
...
cimport cython
cimport cython
...
@@ -395,9 +391,7 @@ positive, by casting the variables to unsigned integer types (if you do have
...
@@ -395,9 +391,7 @@ positive, by casting the variables to unsigned integer types (if you do have
negative values, then this casting will create a very large positive value
negative values, then this casting will create a very large positive value
instead and you will attempt to access out-of-bounds values). Casting is done
instead and you will attempt to access out-of-bounds values). Casting is done
with a special ``<>``-syntax. The code below is changed to use either
with a special ``<>``-syntax. The code below is changed to use either
unsigned ints or casting as appropriate:
unsigned ints or casting as appropriate::
.. sourcecode:: cython
...
...
cdef int s, t # changed
cdef int s, t # changed
...
@@ -456,9 +450,7 @@ function call.)
...
@@ -456,9 +450,7 @@ function call.)
More generic code
More generic code
==================
==================
It would be possible to do:
It would be possible to do::
.. sourcecode:: cython
def naive_convolve(object[DTYPE_t, ndim=2] f, ...):
def naive_convolve(object[DTYPE_t, ndim=2] f, ...):
...
...
docs/overview.rst
View file @
bd2a3d43
.. highlight:: cython
.. _overview-label:
.. _overview-label:
********
********
...
...
docs/pyrex_differences.rst
View file @
bd2a3d43
.. highlight:: cython
Differences between Cython and Pyrex
Differences between Cython and Pyrex
====================================
====================================
...
...
docs/sharing_declarations.rst
View file @
bd2a3d43
.. highlight:: cython
.. _sharing-declarations-label:
.. _sharing-declarations-label:
Sharing Declarations Between Cython Modules
Sharing Declarations Between Cython Modules
...
...
docs/source_files_and_compilation.rst
View file @
bd2a3d43
.. highlight:: cython
.. _compilation_label:
.. _compilation_label:
****************************
****************************
...
...
docs/tutorial.rst
View file @
bd2a3d43
.. highlight:: cython
.. _tutorial_label:
.. _tutorial_label:
*********
*********
...
@@ -107,7 +109,10 @@ Here's a small example showing some of what can be done. It's a routine for
...
@@ -107,7 +109,10 @@ Here's a small example showing some of what can be done. It's a routine for
finding prime numbers. You tell it how many primes you want, and it returns
finding prime numbers. You tell it how many primes you want, and it returns
them as a Python list.
them as a Python list.
:file:`primes.pyx`: ::
:file:`primes.pyx`:
.. sourcecode:: cython
:linenos:
def primes(int kmax):
def primes(int kmax):
cdef int n, k, i
cdef int n, k, i
...
...
docs/wrapping_CPlusPlus.rst
View file @
bd2a3d43
.. highlight:: cython
.. _wrapping-cplusplus-label:
.. _wrapping-cplusplus-label:
Wrapping C++ Classes in Cython
Wrapping C++ Classes in Cython
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment