Copied implementation from CPython. Added the CPython mp tests.