answered 8 years ago
The code that sage uses is here: https://git.sagemath.org/sage.git/tree/src/sage/structure/coerce_actions.pyx#n786