Ondrej Certik wrote: > On Fri, Mar 12, 2010 at 6:28 AM, Lisandro Dalcin <[email protected]> wrote: >> On 11 March 2010 23:14, Ondrej Certik <[email protected]> wrote: > [...] >>> but the rest will be a bit more complicated. Let me know if you think >>> this is the right approach. I guess I could add some cython cmdline >>> option to control the global/local api. >>> >> How about controling global/local api at C compile time, using >> preprocessor definitions? > > But how about the generation of the .cpp file? I need cython to > generate it. But most users imho just need the .h file. > >>> p->insert_object("i", c2py_int(5)); >>> >> I would prefer p->put("i", c2py_int(5)) > > As I wrote, I would actually prefer push. That's what ipython uses > (Brian suggested this to me) and I like it. E.g. push/pull. > > Yours idea would be put/get. I guess that's cool too. I am not a > native speaker, so my intuition might be wrong, but I like to think of > pushing the variables in there, rather than just putting them there. > :) > >>> int i = py2c_int(p->get_object("i")); >>> >> Can you explain me how are you managing reference counting? I think >> that you will need a proxy C++ class to manage incref()/decref() > > Here are the definitions of py2c_int and c2py_int: > > cdef api object c2py_int(int i): > return i > > cdef api int py2c_int(object i): > return i
This sounds like the kind of stuff Convert-XY is doing, except Convert-XY supports many more types... http://conference.scipy.org/proceedings/SciPy2009/paper_4/ """ We present Convert-XY: a new, header-only template library for converting containers between C++ and Python with a simple, succinct syntax. At compile-time, template-based recursive pattern matching is performed on the static structure of the C++ type to build dynamic type checkers and conversion functions. """ -- Dag Sverre _______________________________________________ Cython-dev mailing list [email protected] http://codespeak.net/mailman/listinfo/cython-dev
