Reputation: 14113
In cython , I need to do a system of node with parent and child ( for a kdtree ). I try this:
cdef struct Node:
int id
Node *left_child
Node *right_left
But I get a error where a struct cannot contain itself. I can do that in python, so I supposed it's possible with cython / C.
Upvotes: 1
Views: 1112
Reputation: 636
Cython allows forward definitions, so:
cdef struct Node
cdef struct Node:
int id
Node *left_child
Node *right_left
You may already know this, but Scipy has very nice kdtree implementations in pure Python and Cython.
Upvotes: 2
Reputation: 91
I'm not familiar with cython or cdef--so here goes; have you tried doing this instead?
cdef struct Node:
int id
struct Node *left_child
struct Node *right_left
Upvotes: -1