简体   繁体   中英

how to get a multiple outputs function called in cython

I'm writing a function in cython (to optimize a python function) that uses another cython optimized function which returns a and b. I want to use a and b in the second function to do some calculation and I DON'T KNOW how! Should I use something like an extended type (class, struct???) or there is another way to do it? here are my python function (I'm not an expert but it works very well):

for i in range(n_max):  
    output     = func.func(indata,i) // My tuple [2]
    tmp1       = output[0]
    tmp2       = output[1] 
....other calculations

Any suggestions?

You can use a C struct you write yourself. Easier, if you are compiling using C++ you can use the C++ std::pair . The Cython syntax for it is

from libcpp.vector cimport pair

cdef pair[int, int] myPair2

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM