I've been looking how painful it is to constantly convert between
Python objects and string in C++. Yes, it's easy to write a utility,
but this should be as natural (if not more so, as the length is
explicit) than bytes <-> char*. Several other of the libcpp classes
(vector, map) have natural Python analogues too.
What would people think about making it possible to declare these in a
C++ file? Being able to make arbitrary mappings anywhere between types
is contextless global state that I'd rather avoid, but perhaps special
methods defined on the class such as
cdef extern from "<string>" namespace "std":
cdef cppclass string:
def __object__(sting s):
return s.c_str()[s.size()]
def __create__(object o):
return string(<char*>o, len(o))
...
(names open to suggestions) Then one could write
cdef extern from *:
string c_func(string)
def f(x):
return c_func(x)
- Robert
_______________________________________________
cython-devel mailing list
[email protected]
http://mail.python.org/mailman/listinfo/cython-devel