Hi Ken,

thank you for the inputs. Just one more comment:

I actually find myself often factoring such data out of loops in Python,  
whereas in C I would just leave that to the optimizer/compiler.

The compiler in CPython can't really do that because it's not safe in Python. 
The user could've overridden `__add__` to do more things than just addition.

I'm totally aware that Python, or dynamic languages in general, are terrible for any optimizer, because there is basically nothing that it can be sure about. However, this is exactly the point of marking functions as "pure". It would not make the code technically safe to optimize, but transfer the responsibility from the interpreter to the programmer. If the programmer says that something is safe to optimize/cache, then the interpreter can't be blamed if something breaks when it actually does so.

On the other hand, a language as dynamic as Python probably is just not designed for an optimizer, so either you do it by hand or use an extension module to speed critical parts up. Fair enough.

Best regards,
Philipp
_______________________________________________
Python-Dev mailing list -- python-dev@python.org
To unsubscribe send an email to python-dev-le...@python.org
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at 
https://mail.python.org/archives/list/python-dev@python.org/message/JA7YE6V4APZT7QZXA6SASVWXEQJTWY5K/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to