Fastest way to determine if an integer’s square root is an integer

I figured out a method that works ~35% faster than your 6bits+Carmack+sqrt code, at least with my CPU (x86) and programming language (C/C++). Your results may vary, especially because I don’t know how the Java factor will play out. My approach is threefold: First, filter out obvious answers. This includes negative numbers and looking at … Read more

How do I profile a Python script?

Python includes a profiler called cProfile. It not only gives the total running time, but also times each function separately, and tells you how many times each function was called, making it easy to determine where you should make optimizations. You can call it from within your code, or from the interpreter, like this: import … Read more

Improve INSERT-per-second performance of SQLite

Several tips: Put inserts/updates in a transaction. For older versions of SQLite – Consider a less paranoid journal mode (pragma journal_mode). There is NORMAL, and then there is OFF, which can significantly increase insert speed if you’re not too worried about the database possibly getting corrupted if the OS crashes. If your application crashes the … Read more

tech