Hello, I am trying to use C++ STL, specifically container <vector> and <set>. But I just find a little discription in <Cython Manual>. And I couldn't even to get the example to work.
Here is what I do:
1. <stl.h>:
#include <vector>
2. <pstl.pyx>:
cdef extern from "stl.h":
ctypedef struct intvec "std::vector<int>":
void (* push_back) (int elem)
intvec intvec_factory "std::vector<int>" (int len)
def main():
cdef intvec v = intvec_factory(2)
v.push_back(3)
print 'Hello'
3.<setup.py>:
from distutils.core import setup
from distutils.extension import Extension
from Cython.Distutils import build_ext
setup(
name = 'Demos',
ext_modules=[
Extension("test",
sources=["pstl.pyx"],
include_dirs=["."],
language="c++"),
],
cmdclass = {'build_ext': build_ext},
)
4. python setup.py build_ext --inplace
When I import "pstl", there is an ImportError.
I am totally frustrated. And I commit that: I didn't finish reading Cython
Manual. It's not that easy to understand and it has too few examples.
Thanks.
Jankins
<<spacer.gif>>
<<tl.jpg>>
<<t_bg.jpg>>
<<bg.jpg>>
<<d_bg.jpg>>
<<dr.jpg>>
_______________________________________________ Cython-dev mailing list [email protected] http://codespeak.net/mailman/listinfo/cython-dev
