[Python-Dev] longobject.c & ob_size
"Martin v. Löwis"
martin at v.loewis.de
Sun Apr 3 18:03:29 CEST 2005
Michael Hudson wrote:
> Asking mostly for curiousity, how hard would it be to have longs store
> their sign bit somewhere less aggravating? It seems to me that the
> top bit of ob_digit[0] is always 0, for example, and I'm sure this
> would result no less convolution in longobject.c it'd be considerably
> more localized convolution.
I think the amount of special-casing that you need would remain the
same - i.e. you would have to mask out the sign before performing
the algorithms, then bring it back in. Masking out the bit from digit[0]
might slow down the algorithms somewhat, because you would probably mask
it out from every digit, not only digit[0] (or else test for digit[0],
which test would then be performed for all digits).
You would also have to keep the special case for 0L, which has
ob_size==0 (i.e. doesn't have digit[0]).
That said, I think the change could be implemented within a few hours,
taking a day to make the testsuite run again; depending on the review
process, you might need two releases to fix the bugs (but then, it
is also reasonable to expect to get it right the first time).
Regards,
Martin
More information about the Python-Dev
mailing list