xor: how come so slow?

Lawrence D'Oliveiro ldo at geek-central.gen.new_zealand
Sat Oct 18 23:38:37 EDT 2008


In message <010a9c3f$0$20653$c3e8da3 at news.astraweb.com>, Steven D'Aprano
wrote:

> On Sat, 18 Oct 2008 09:16:11 +1300, Lawrence D'Oliveiro wrote:
> 
>> Data can come in fractional bits. That's how compression works.
> 
> If you don't believe me, try compressing a single bit and see if you get
> a "fractional bit".

If both states of the bit are not equally likely, then you do indeed have a
fractional bit, since

    nrbits = (- logbase2(P[bit = 0]) - logbase2(P[bit = 1])) / 2



More information about the Python-list mailing list