Comparing different analogous approaches for efficiency in Python