computers

You are currently browsing articles tagged computers.

I was bored last night so I was tinkering with Python. I’m not a programmer. I tinker.  First thing I do  with a programming language is write Fibonacci sequence functions (it’s a good way of getting a sense of things):

def fib4(current=1,last=0,inclusive='y',count=10):
    if inclusive==('y' or 'Y'):
        ser=[last,current]
    else:
        ser=[]
    while count>0:
        ser.append(current+last)
        current=last+current
        last=current-last
        count=count-1
    return(ser)

print fib4(1,0,'y',100)

That was the fourth one, and it’s probably really inefficient, because I’m an amateur. I made a variety.

Initially I forgot the count decrement (count=count-1) which meant the while loop never exited.  Which meant the (ser) array was having hundreds of Fibonacci numbers appended per second.  It was eating all of my system memory.  I didn’t know that because I’d left to go to the toilet. I’m sure uncontrolled allocation of memory like that would slow any operating system.   Memory is finite.

But after 2 minutes of the fibonnaci function running it took me 10 minutes to close Python down.  Another five minutes for Vista (not SP1)  to become usable again.   I cannot remember Linux, Windows XP, or OS-X being that susceptable to an idiot’s program and have that glacial degree of slow down. It was like a fork bomb.

With Linux I usually alt-F1′d to an empty terminal, logged in, did a ‘ps aux | grep programname’ then ‘kill -9 process_id’.  And Windows XP seemed to be more responsive to the ‘ctrl-alt-delete’ system call.  With OS-X I usually have a terminal open and kill the process from there.

* Briefly.