cython

Using cython .pxd files to Augment pure python files

Following the example here, "Augementing .pxd", I'm trying to use ".pxd" files to augment a pure python file. (Add type definitions external to the pure python file). python file: class A(object): def foo(self, i=3, x=None): print "Big" if i > 1000 else "Small" pxd file: cdef class A: cpdef foo(self, int i, x) I've...

Cython C++ and std::string

What is the best way of using C++ standard std::string from cython? The last cython distribution should make it easy anyway, but I wonder why there are wrappers for std::vector and not for std::string... ...

Can Cython speed up array of object iteration?

I want to speed up the following code using cython: class A(object): cdef fun(self): return 3 class B(object): cdef fun(self): return 2 def test(): cdef int x, y, i, s = 0 a = [ [A(), B()], [B(), A()]] for i in xrange(1000): for x in xrange(2): for y in xrange(2): ...

Cython problem in Windows XP: "error: Unable to find vcvarsall.bat"

Cython version is 0.13, Python 3.1 I have tried all "solutions" in Cython FAQ, but to no avail. My version of Visual Studio is 7.1 and its directory doesn't contain vcvarsall.bat. Is this problem have a solution? ...

What is the easiest way to make an optional C extension for a python package?

I've created a C extension that I'd like to enable in my Python package (using setuptools) only if a command line option is passed in. What is the easiest way to do this? I can't seem to find any straightforward ways of going about this. ...