From: Robert Bradshaw <rober...@gmail.com>
Date: Fri, 23 Mar 2012 14:07:59 -0700
Local: Fri, Mar 23 2012 5:07 pm
Subject: Re: [cython-users] Specify C++ template type in Python
On Fri, Mar 23, 2012 at 4:44 AM, csd <charan...@gmail.com> wrote: No, this isn't (currently) possible. The issue is that the C++ > I wanted to wrap some C++ code using Cython (to be callable in Python) > and wondered if one could specify the template type in Python itself > somehow. To illustrate the problem, consider the code which wraps the C > ++ vector class in Cython (taken from http://docs.cython.org/src/userguide/wrapping_CPlusPlus.html > ) > from cython.operator cimport dereference as deref, preincrement as inc > cdef extern from "<vector>" namespace "std": > Ideally I would like to make this code callable from Python using > a = PyVector(int) > where int becomes the template type. > My incorrect attempt so far looks like this: > cdef class PyVector: > but I need to specify the template type of the instance variable template type needs to be determined at compile time, but you're trying to defer the decision to runtime. Compiling several different specializations is the only way to do it. You may also want to take a look at fused types (though this is not - Robert You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
| ||||||||||||||