How can I build a motorcade in Keaton?

I'm new to cython, and I'm just looking for an easy way to cast a numpy array into a tuple, which can then be added to the dictionary and / or found in the dictionary.

In CPython, I can use PyTuple_New and iterate over the values โ€‹โ€‹of the array (adding each of them to the tuple, as if I were adding them to the list).

Cython does not seem to have the usual CPython features. How can I rotate an array:

array([1,2,3]) 

in the tuple:

 (1, 2, 3) 
+4
source share
1 answer

Cython is a superset of Python, so any valid Python code is valid Cython code. In this case, if you have a NumPy array, just passing it to the constructor of the tuple class should work just fine (as in normal Python).

 a = np.array([1, 2, 3]) t = tuple(a) 

Cython will take care of converting these constructs into corresponding C function calls.

+3
source

Source: https://habr.com/ru/post/1502124/


All Articles