Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
gists
/
cython-cwrapper
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Registry
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
cd59daea
authored
Sep 28, 2011
by
Gael varoquaux
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rename to have README stand out on the gist
parent
ff802218
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
32 additions
and
0 deletions
+32
-0
00README.rst
+32
-0
No files found.
00README.rst
0 → 100644
View file @
cd59daea
============================================================================
Cython example of exposing C-computed arrays in Python without data copies
============================================================================
The goal of this example is to show how an existing C codebase for
numerical computing (here `c_code.c`) can be wrapped in Cython to be
exposed in Python.
The meat of the example is that the data is allocated in C, but exposed
in Python without a copy using the `PyArray_SimpleNewFromData` numpy
function in the Cython file `cython_wrapper.pyx`.
Note that the ownership of the memory is then handed off to the Python
VM, and there is no control of when Python will deallocate the memory. If
the memory is still being used by the C code, please refer to the
following blog post by Travis Oliphant:
http://blog.enthought.com/python/numpy-arrays-with-pre-allocated-memory
To build it you will need Cython, numpy, and a C compiler.
Run::
$ python setup.py build_ext --i
to build the C extension in-place.
To test the C-Python bindings, run the `test.py` file.
____
:Author: Gael Varoquaux
:License: BSD
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