The latest patch from Victor looks good. A few comments:
(1) the number of bits should be computed first directly using C
arithmetic, and only recomputed using PyLong arithmetic if the C
computations overflow. For one thing, overflow is going to be very rare
in practice; for another, in the sort of applications that use
.numbits(), speed of numbits() is often critical.
(2) Just as a matter of style, I think "if (x == NULL)" is preferable
to "if (!x)". At any rate, the former style is much more common in
Python source.
(3) the reference counting all looks good.
(4) I quite like the idea of having numbits be a property rather than a
method---might still be worth considering? |