What is a Tight Loop?

One often hears about tight loops in the context of programming. I never really got what it meant. Until today.

A tight loop may be described as a loop that does very little work itself but has an impact on the performance of the larger program. For example, in an O(n) loop the faster it can execute each iteration the tighter it is.

Read more …

Python readline Bug

Problem

In the Python interpreter whenever I hit enter it would show a blank line without a prompt and I'd have to press enter again to see the prompt. When I exited the interpreter the terminal would not show anything I typed. Pressing the return key would show my shell prompt on the same line. Up arrow or down arrow keys did not make any difference. reset was a last resort.

For example,

Python 3.4.3 (default, Aug 26 2015, 18:29:14)
[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.56)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> abs(1-0)
>>> 1

>>> ^D>>>
~ $ ~ $ ~ $ reset

Read more …