Relay python implementation for C