Extracted pylru impl from core.