Contents
Software Bugs
Leaks and Races
75% correct vs 50% correct
Probabilistic algorithms
Fixing is_fprime
Defensive programming
Defect halflife
How did that code ever work?
Conclusions
Source code
Which clock is the best?
We can easily rule the one which has stopped …
Or can we? In “The Rectory Umbrella” Lewis Carroll argues otherwise.
Which is better, a clock that is right only once a year, or a clock that is right twice every day?
“The latter,” you reply, “unquestionably.”
Very good, now attend.
I have two clocks: one doesn’t go at all, and the other loses a minute a day: which would you prefer? “The losing one,” you answer, “without a doubt.” Now observe: the one which loses a minute a day has to lose twelve hours, or seven hundred and twenty minutes before it is right again, consequently it is on...
Content suppressed by ://URLFAN, for full article visit source
Sugar PiePost Date: 2008-03-06 00:00:00
Question: in the code snippet bleow, what does the result stream, rs, approximate?
from itertools import count, ifilter, izip
from random import random as xy
from math import hypot
pt = lambda: (xy(), xy())
on = ifilter(lambda n: hypot(*pt()) < 1., count(1))
rs = (4. * j / i for i, j in izip(on, count(1)))
The code isn’t wilfully obscure but I’ll admit it’s unusual. A...
Tracing function calls using Python decoratorsPost Date: 2008-03-10 00:00:00
Contents
Introduction
A less invasive way
Decorators
Improving echo
Wider application
Work in progress
Source Code
Credits
@ end
Introduction
Let’s suppose you want to trace calls to a function. That is, every time the function gets called, you want to print out its name and the values of any arguments passed by the caller. To provide a concrete example, here’s a function which calculates the dot product of two ve...
Drawing ChessboardsPost Date: 2008-03-18 00:00:00
Contents
The Python Imaging Library
ImageMagick
Google Chart API
ASCII Text
Unicode Block Elements
And more
Why?
Teaser
Thanks
I wanted a picture of a chessboard. Rather than boot up some drawing software and cut and paste black and white squares I decided to write a program to create the picture.
If you’d like to know why anyone would ever create work for themselves in this way, skip to the end of this article, where y...