I have some notes regarding the python style. I didn't check the algorithms themselves.
+ assert p >= 0 and p <= 1, 'p must be in the range [0,1]' Python supports the expression '0 <= p <= 1', which is slightly easier to read. + def bisect_k(low_k, high_k): + """ + Recursive function to perform the search. + """ This part looks a lot like the stdlib 'bisect' module. That one is expecting to receive a sequence, and yours calculates elements on demand, but you could make an object that lazily runs pr_backup_file_loss() when bisect asks for an element. + if k > n/2: + k = n - k + + accum = 1.0 + for i in range(1, k+1): + accum = accum * (n - k + i) / i; These lines are doing integer division for legacy reasons. It would be more future proof and robust to put 'from __future__ import division' at the top of the file and use the explicit // operator in all the cases where you want int division. + return long(accum + 0.5) long is going away, and in modern python versions, I think int can do everything that long can. _______________________________________________ tahoe-dev mailing list [email protected] http://allmydata.org/cgi-bin/mailman/listinfo/tahoe-dev
