pure python and c implement