How to make upbge(bge) script to improve logic run time and increase framerate

If you are having these problems that I was having try looking at these post they help me solve this problem.

https://blenderartists.org/t/how-to-do-threading-in-upbge-bge/1420451/11

https://blenderartists.org/t/how-to-add-objects-once-in-range-from-dictionary/1422979/37