General (non-performance) review:
- Don't run words together like that in identifiers. PEP-8 says you should use underscores as word separators; e.g.
distancia_puntorather than.distanciapunto - The function's doc-commentdocstring is missing. It needs to describe the meaning of the arguments, and also the global variable (
transformer) that is referenced. - Prefer to pass
transformeras an argument rather than using a global variable. - Choose a better exceptional return (10 000 metres is a plausible distance between two points on Earth; 50 000 is impossible;
Noneclearly distinguishes from an actual value). Better, don't catch the exception and instead allow the caller to decide what should happen. - The final line (outside the function) references another global into which I have no insight.