cdef public class Children [object soyChildren, type soyChildrenType]:
This is a thread-safe C array of Python objects for "Parent" classes.
It's append, index, and remove methods are identical to Python lists.
The up, down, top, bottom, and move methods move an object in the array.
The lock and unlock methods control the mutex.
cdef int size
cdef int current
cdef void **list
cdef PyThread_type_lock lock
def void __new__(self)
cdef void lock(self)
cdef void unlock(self)
cdef void append(self, void *child)
cdef int index(self, void *child)
cdef void swap(self, int first, int second)
cdef void up(self, void *child)
cdef void down(self, void *child)
cdef void top(self, void *child)
cdef void bottom(self, void *child)
cdef void remove(self, void *child)
Instances of this class must be locked/unlocked externally. When the coreloop traverses the various trees it'll lock/unlock thus blocking Python's execution only if Python is trying to modify the children while it's being processed. Much better than using the GIL.
This is in a soy._imports module to keep it out of the way and attached as a cdef attribute to any "parent" class. A similar Child class will reference these methods and can be inherited by the base types which need to attach to a parent.