Cython 0.16 C++ Demo - Gists · GitHub
Có thể bạn quan tâm
Skip to content Search Gists Search Gists All gists Back to GitHub Sign in Sign up Sign in Sign up You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session. Dismiss alert {{ message }}
npinto/.gitignore Created August 1, 2012 23:40 Show Gist options
Raw _demo.pyx This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters Show hidden characters
Raw demo.cpp This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters Show hidden characters
Raw demo.h This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters Show hidden characters
Raw setup.py This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters Show hidden characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment You can’t perform that action at this time.
Instantly share code, notes, and snippets.
- Download ZIP
- Star (0) You must be signed in to star a gist
- Fork (0) You must be signed in to fork a gist
- Embed Select an option
- Embed Embed this gist in your website.
- Share Copy sharable link for this gist.
- Clone via HTTPS Clone using the web URL.
No results found
Learn more about clone URLs Clone this repository at <script src="https://gist.github.com/npinto/3231603.js"></script> - Save npinto/3231603 to your computer and use it in GitHub Desktop.
- Embed Embed this gist in your website.
- Share Copy sharable link for this gist.
- Clone via HTTPS Clone using the web URL.
No results found
Learn more about clone URLs Clone this repository at <script src="https://gist.github.com/npinto/3231603.js"></script> Save npinto/3231603 to your computer and use it in GitHub Desktop. Download ZIP Cython 0.16 C++ Demo Raw .gitignore This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters Show hidden characters| *.so |
| _demo.cpp |
| build |
| # distutils: language = c++ |
| # distutils: sources = demo.cpp |
| cdef extern from "demo.h" namespace "demo": |
| cdef int test(float*, int) |
| import numpy as np |
| cimport numpy as cnp |
| def func(cnp.ndarray[cnp.float32_t, ndim=1] arr, |
| size=1, |
| ): |
| assert arr.dtype == 'float32' |
| ptr = arr.data |
| return test(<float*>arr.data, <Py_ssize_t>size) |
| #include <iostream> |
| #include "demo.h" |
| using namespace std; |
| int demo::test(float* arr, int size) |
| { |
| int i; |
| for(i=0; i < size; ++i) |
| cout << i << ":" << ((float*)arr)[i] << endl; |
| return i; |
| } |
| namespace demo { |
| int test(float* arr, int size); |
| } |
| from distutils.core import setup |
| from distutils.extension import Extension |
| from Cython.Distutils import build_ext |
| import numpy as np |
| setup( |
| ext_modules=[ |
| Extension("_demo", |
| sources=["_demo.pyx", "demo.cpp"], |
| language="c++", |
| include_dirs=[np.get_include()], |
| ), |
| ], |
| cmdclass={'build_ext': build_ext} |
| ) |
| import _demo |
| arr = np.random.randn(10).astype('f') |
| print _demo.func(arr, size=len(arr)) |
Từ khóa » Cython C++ Github
-
Cython/wrapping_t At Master - GitHub
-
Cython C++ Example - Gists · GitHub
-
[ENH] C++ Variant · Issue #4677 · Cython/cython - GitHub
-
Cython · GitHub Topics
-
Cython C++ Example - Gists · GitHub
-
A Few Quick Tutorials On Using C++ Function In Python Code With Cython
-
Cython/cython: The Most Widely Used Python To C Compiler - GitHub
-
Cython · GitHub Topics
-
Cython-wrapper · GitHub Topics
-
Molpopgen/cython_mcpp: Glue Layer Between Cython And C++11 ...
-
Add C++ "to_string()" Function To Declarations. - GitHub
-
David-cortes/cycereal: C++ Cereal Headers As An ... - GitHub
-
Cython-wrapper · GitHub Topics
-
Allow Sharing C++ Classes Across Modules · Issue #4561 - GitHub