Mar-25-2022, 06:30 AM
Speeding up loops is not your problem. Your main problem is you don't know Python very well and you are trying to use it in a way it is not meant to be used. You are using Python like it is C++ and disappointed that it does not act like C++. If you want a language to act like C++ maybe you should use C++?
You can do what you want to do using Python, but you can't really do it the way you are trying. Larz gives you good advice and you just decide to ignore it because it doesn't fit with you view. Sorry, but Python was not written for you. If you want to use Python you have to change your ways to fit better with what Python provides. One thing that Python is particularly bad at is loops. Some loops can be sped up, but many cannot. Quite often people trying to speed up their code using something like numba and see no benefit or even worse results. Like Python, these tools are meant to be used in a certain way, and if you don't follow their rules, they don't work.
You can do what you want to do using Python, but you can't really do it the way you are trying. Larz gives you good advice and you just decide to ignore it because it doesn't fit with you view. Sorry, but Python was not written for you. If you want to use Python you have to change your ways to fit better with what Python provides. One thing that Python is particularly bad at is loops. Some loops can be sped up, but many cannot. Quite often people trying to speed up their code using something like numba and see no benefit or even worse results. Like Python, these tools are meant to be used in a certain way, and if you don't follow their rules, they don't work.