summaryrefslogtreecommitdiffstats
path: root/Objects/longobject.c
diff options
context:
space:
mode:
authorChristian Heimes <christian@cheimes.de>2007-12-19 02:37:44 (GMT)
committerChristian Heimes <christian@cheimes.de>2007-12-19 02:37:44 (GMT)
commite93237dfcc4ee4feee62adafb4e7899487ca864b (patch)
treeb78abc265e7fb10639492f62e4ffd0ce1bcc67af /Objects/longobject.c
parentd586559c31b77938b514cec99f2f8b431a34dff5 (diff)
downloadcpython-e93237dfcc4ee4feee62adafb4e7899487ca864b.zip
cpython-e93237dfcc4ee4feee62adafb4e7899487ca864b.tar.gz
cpython-e93237dfcc4ee4feee62adafb4e7899487ca864b.tar.bz2
#1629: Renamed Py_Size, Py_Type and Py_Refcnt to Py_SIZE, Py_TYPE and Py_REFCNT. Macros for b/w compatibility are available.
Diffstat (limited to 'Objects/longobject.c')
-rw-r--r--Objects/longobject.c178
1 files changed, 89 insertions, 89 deletions
diff --git a/Objects/longobject.c b/Objects/longobject.c
index f14f298..85e862a 100644
--- a/Objects/longobject.c
+++ b/Objects/longobject.c
@@ -50,13 +50,13 @@ static PyObject *long_format(PyObject *aa, int base, int addL);
static PyLongObject *
long_normalize(register PyLongObject *v)
{
- Py_ssize_t j = ABS(Py_Size(v));
+ Py_ssize_t j = ABS(Py_SIZE(v));
Py_ssize_t i = j;
while (i > 0 && v->ob_digit[i-1] == 0)
--i;
if (i != j)
- Py_Size(v) = (Py_Size(v) < 0) ? -(i) : i;
+ Py_SIZE(v) = (Py_SIZE(v) < 0) ? -(i) : i;
return v;
}
@@ -147,7 +147,7 @@ PyLong_FromUnsignedLong(unsigned long ival)
v = _PyLong_New(ndigits);
if (v != NULL) {
digit *p = v->ob_digit;
- Py_Size(v) = ndigits;
+ Py_SIZE(v) = ndigits;
while (ival) {
*p++ = (digit)(ival & MASK);
ival >>= SHIFT;
@@ -189,7 +189,7 @@ PyLong_FromDouble(double dval)
frac = ldexp(frac, SHIFT);
}
if (neg)
- Py_Size(v) = -(Py_Size(v));
+ Py_SIZE(v) = -(Py_SIZE(v));
return (PyObject *)v;
}
@@ -323,7 +323,7 @@ PyLong_AsUnsignedLong(PyObject *vv)
return (unsigned long) -1;
}
v = (PyLongObject *)vv;
- i = Py_Size(v);
+ i = Py_SIZE(v);
x = 0;
if (i < 0) {
PyErr_SetString(PyExc_OverflowError,
@@ -381,7 +381,7 @@ _PyLong_Sign(PyObject *vv)
assert(v != NULL);
assert(PyLong_Check(v));
- return Py_Size(v) == 0 ? 0 : (Py_Size(v) < 0 ? -1 : 1);
+ return Py_SIZE(v) == 0 ? 0 : (Py_SIZE(v) < 0 ? -1 : 1);
}
size_t
@@ -393,7 +393,7 @@ _PyLong_NumBits(PyObject *vv)
assert(v != NULL);
assert(PyLong_Check(v));
- ndigits = ABS(Py_Size(v));
+ ndigits = ABS(Py_SIZE(v));
assert(ndigits == 0 || v->ob_digit[ndigits - 1] != 0);
if (ndigits > 0) {
digit msd = v->ob_digit[ndigits - 1];
@@ -519,7 +519,7 @@ _PyLong_FromByteArray(const unsigned char* bytes, size_t n,
}
}
- Py_Size(v) = is_signed ? -idigit : idigit;
+ Py_SIZE(v) = is_signed ? -idigit : idigit;
return (PyObject *)long_normalize(v);
}
@@ -540,8 +540,8 @@ _PyLong_AsByteArray(PyLongObject* v,
assert(v != NULL && PyLong_Check(v));
- if (Py_Size(v) < 0) {
- ndigits = -(Py_Size(v));
+ if (Py_SIZE(v) < 0) {
+ ndigits = -(Py_SIZE(v));
if (!is_signed) {
PyErr_SetString(PyExc_TypeError,
"can't convert negative long to unsigned");
@@ -550,7 +550,7 @@ _PyLong_AsByteArray(PyLongObject* v,
do_twos_comp = 1;
}
else {
- ndigits = Py_Size(v);
+ ndigits = Py_SIZE(v);
do_twos_comp = 0;
}
@@ -686,7 +686,7 @@ _PyLong_AsScaledDouble(PyObject *vv, int *exponent)
return -1;
}
v = (PyLongObject *)vv;
- i = Py_Size(v);
+ i = Py_SIZE(v);
sign = 1;
if (i < 0) {
sign = -1;
@@ -847,7 +847,7 @@ PyLong_FromLongLong(PY_LONG_LONG ival)
v = _PyLong_New(ndigits);
if (v != NULL) {
digit *p = v->ob_digit;
- Py_Size(v) = negative ? -ndigits : ndigits;
+ Py_SIZE(v) = negative ? -ndigits : ndigits;
t = (unsigned PY_LONG_LONG)ival;
while (t) {
*p++ = (digit)(t & MASK);
@@ -875,7 +875,7 @@ PyLong_FromUnsignedLongLong(unsigned PY_LONG_LONG ival)
v = _PyLong_New(ndigits);
if (v != NULL) {
digit *p = v->ob_digit;
- Py_Size(v) = ndigits;
+ Py_SIZE(v) = ndigits;
while (ival) {
*p++ = (digit)(ival & MASK);
ival >>= SHIFT;
@@ -1117,7 +1117,7 @@ mul1(PyLongObject *a, wdigit n)
static PyLongObject *
muladd1(PyLongObject *a, wdigit n, wdigit extra)
{
- Py_ssize_t size_a = ABS(Py_Size(a));
+ Py_ssize_t size_a = ABS(Py_SIZE(a));
PyLongObject *z = _PyLong_New(size_a+1);
twodigits carry = extra;
Py_ssize_t i;
@@ -1163,7 +1163,7 @@ inplace_divrem1(digit *pout, digit *pin, Py_ssize_t size, digit n)
static PyLongObject *
divrem1(PyLongObject *a, digit n, digit *prem)
{
- const Py_ssize_t size = ABS(Py_Size(a));
+ const Py_ssize_t size = ABS(Py_SIZE(a));
PyLongObject *z;
assert(n > 0 && n <= MASK);
@@ -1194,7 +1194,7 @@ long_format(PyObject *aa, int base, int addL)
return NULL;
}
assert(base >= 2 && base <= 36);
- size_a = ABS(Py_Size(a));
+ size_a = ABS(Py_SIZE(a));
/* Compute a rough upper bound for the length of the string */
i = base;
@@ -1597,7 +1597,7 @@ digit beyond the first.
z = _PyLong_New(size_z);
if (z == NULL)
return NULL;
- Py_Size(z) = 0;
+ Py_SIZE(z) = 0;
/* `convwidth` consecutive input digits are treated as a single
* digit in base `convmultmax`.
@@ -1627,7 +1627,7 @@ digit beyond the first.
/* Multiply z by convmult, and add c. */
pz = z->ob_digit;
- pzstop = pz + Py_Size(z);
+ pzstop = pz + Py_SIZE(z);
for (; pz < pzstop; ++pz) {
c += (twodigits)*pz * convmult;
*pz = (digit)(c & MASK);
@@ -1636,14 +1636,14 @@ digit beyond the first.
/* carry off the current end? */
if (c) {
assert(c < BASE);
- if (Py_Size(z) < size_z) {
+ if (Py_SIZE(z) < size_z) {
*pz = (digit)c;
- ++Py_Size(z);
+ ++Py_SIZE(z);
}
else {
PyLongObject *tmp;
/* Extremely rare. Get more space. */
- assert(Py_Size(z) == size_z);
+ assert(Py_SIZE(z) == size_z);
tmp = _PyLong_New(size_z + 1);
if (tmp == NULL) {
Py_DECREF(z);
@@ -1665,7 +1665,7 @@ digit beyond the first.
if (str == start)
goto onError;
if (sign < 0)
- Py_Size(z) = -(Py_Size(z));
+ Py_SIZE(z) = -(Py_SIZE(z));
if (*str == 'L' || *str == 'l')
str++;
while (*str && isspace(Py_CHARMASK(*str)))
@@ -1726,7 +1726,7 @@ static int
long_divrem(PyLongObject *a, PyLongObject *b,
PyLongObject **pdiv, PyLongObject **prem)
{
- Py_ssize_t size_a = ABS(Py_Size(a)), size_b = ABS(Py_Size(b));
+ Py_ssize_t size_a = ABS(Py_SIZE(a)), size_b = ABS(Py_SIZE(b));
PyLongObject *z;
if (size_b == 0) {
@@ -1778,7 +1778,7 @@ long_divrem(PyLongObject *a, PyLongObject *b,
static PyLongObject *
x_divrem(PyLongObject *v1, PyLongObject *w1, PyLongObject **prem)
{
- Py_ssize_t size_v = ABS(Py_Size(v1)), size_w = ABS(Py_Size(w1));
+ Py_ssize_t size_v = ABS(Py_SIZE(v1)), size_w = ABS(Py_SIZE(w1));
digit d = (digit) ((twodigits)BASE / (w1->ob_digit[size_w-1] + 1));
PyLongObject *v = mul1(v1, d);
PyLongObject *w = mul1(w1, d);
@@ -1792,10 +1792,10 @@ x_divrem(PyLongObject *v1, PyLongObject *w1, PyLongObject **prem)
}
assert(size_v >= size_w && size_w > 1); /* Assert checks by div() */
- assert(Py_Refcnt(v) == 1); /* Since v will be used as accumulator! */
- assert(size_w == ABS(Py_Size(w))); /* That's how d was calculated */
+ assert(Py_REFCNT(v) == 1); /* Since v will be used as accumulator! */
+ assert(size_w == ABS(Py_SIZE(w))); /* That's how d was calculated */
- size_v = ABS(Py_Size(v));
+ size_v = ABS(Py_SIZE(v));
k = size_v - size_w;
a = _PyLong_New(k + 1);
@@ -1878,7 +1878,7 @@ x_divrem(PyLongObject *v1, PyLongObject *w1, PyLongObject **prem)
static void
long_dealloc(PyObject *v)
{
- Py_Type(v)->tp_free(v);
+ Py_TYPE(v)->tp_free(v);
}
static PyObject *
@@ -1898,21 +1898,21 @@ long_compare(PyLongObject *a, PyLongObject *b)
{
Py_ssize_t sign;
- if (Py_Size(a) != Py_Size(b)) {
- if (ABS(Py_Size(a)) == 0 && ABS(Py_Size(b)) == 0)
+ if (Py_SIZE(a) != Py_SIZE(b)) {
+ if (ABS(Py_SIZE(a)) == 0 && ABS(Py_SIZE(b)) == 0)
sign = 0;
else
- sign = Py_Size(a) - Py_Size(b);
+ sign = Py_SIZE(a) - Py_SIZE(b);
}
else {
- Py_ssize_t i = ABS(Py_Size(a));
+ Py_ssize_t i = ABS(Py_SIZE(a));
while (--i >= 0 && a->ob_digit[i] == b->ob_digit[i])
;
if (i < 0)
sign = 0;
else {
sign = (int)a->ob_digit[i] - (int)b->ob_digit[i];
- if (Py_Size(a) < 0)
+ if (Py_SIZE(a) < 0)
sign = -sign;
}
}
@@ -1963,7 +1963,7 @@ long_hash(PyLongObject *v)
static PyLongObject *
x_add(PyLongObject *a, PyLongObject *b)
{
- Py_ssize_t size_a = ABS(Py_Size(a)), size_b = ABS(Py_Size(b));
+ Py_ssize_t size_a = ABS(Py_SIZE(a)), size_b = ABS(Py_SIZE(b));
PyLongObject *z;
int i;
digit carry = 0;
@@ -1997,7 +1997,7 @@ x_add(PyLongObject *a, PyLongObject *b)
static PyLongObject *
x_sub(PyLongObject *a, PyLongObject *b)
{
- Py_ssize_t size_a = ABS(Py_Size(a)), size_b = ABS(Py_Size(b));
+ Py_ssize_t size_a = ABS(Py_SIZE(a)), size_b = ABS(Py_SIZE(b));
PyLongObject *z;
Py_ssize_t i;
int sign = 1;
@@ -2107,15 +2107,15 @@ static PyLongObject *
x_mul(PyLongObject *a, PyLongObject *b)
{
PyLongObject *z;
- Py_ssize_t size_a = ABS(Py_Size(a));
- Py_ssize_t size_b = ABS(Py_Size(b));
+ Py_ssize_t size_a = ABS(Py_SIZE(a));
+ Py_ssize_t size_b = ABS(Py_SIZE(b));
Py_ssize_t i;
z = _PyLong_New(size_a + size_b);
if (z == NULL)
return NULL;
- memset(z->ob_digit, 0, Py_Size(z) * sizeof(digit));
+ memset(z->ob_digit, 0, Py_SIZE(z) * sizeof(digit));
if (a == b) {
/* Efficient squaring per HAC, Algorithm 14.16:
* http://www.cacr.math.uwaterloo.ca/hac/about/chap14.pdf
@@ -2199,7 +2199,7 @@ kmul_split(PyLongObject *n, Py_ssize_t size, PyLongObject **high, PyLongObject *
{
PyLongObject *hi, *lo;
Py_ssize_t size_lo, size_hi;
- const Py_ssize_t size_n = ABS(Py_Size(n));
+ const Py_ssize_t size_n = ABS(Py_SIZE(n));
size_lo = MIN(size_n, size);
size_hi = size_n - size_lo;
@@ -2228,8 +2228,8 @@ static PyLongObject *k_lopsided_mul(PyLongObject *a, PyLongObject *b);
static PyLongObject *
k_mul(PyLongObject *a, PyLongObject *b)
{
- Py_ssize_t asize = ABS(Py_Size(a));
- Py_ssize_t bsize = ABS(Py_Size(b));
+ Py_ssize_t asize = ABS(Py_SIZE(a));
+ Py_ssize_t bsize = ABS(Py_SIZE(b));
PyLongObject *ah = NULL;
PyLongObject *al = NULL;
PyLongObject *bh = NULL;
@@ -2281,7 +2281,7 @@ k_mul(PyLongObject *a, PyLongObject *b)
/* Split a & b into hi & lo pieces. */
shift = bsize >> 1;
if (kmul_split(a, shift, &ah, &al) < 0) goto fail;
- assert(Py_Size(ah) > 0); /* the split isn't degenerate */
+ assert(Py_SIZE(ah) > 0); /* the split isn't degenerate */
if (a == b) {
bh = ah;
@@ -2312,20 +2312,20 @@ k_mul(PyLongObject *a, PyLongObject *b)
if (ret == NULL) goto fail;
#ifdef Py_DEBUG
/* Fill with trash, to catch reference to uninitialized digits. */
- memset(ret->ob_digit, 0xDF, Py_Size(ret) * sizeof(digit));
+ memset(ret->ob_digit, 0xDF, Py_SIZE(ret) * sizeof(digit));
#endif
/* 2. t1 <- ah*bh, and copy into high digits of result. */
if ((t1 = k_mul(ah, bh)) == NULL) goto fail;
- assert(Py_Size(t1) >= 0);
- assert(2*shift + Py_Size(t1) <= Py_Size(ret));
+ assert(Py_SIZE(t1) >= 0);
+ assert(2*shift + Py_SIZE(t1) <= Py_SIZE(ret));
memcpy(ret->ob_digit + 2*shift, t1->ob_digit,
- Py_Size(t1) * sizeof(digit));
+ Py_SIZE(t1) * sizeof(digit));
/* Zero-out the digits higher than the ah*bh copy. */
- i = Py_Size(ret) - 2*shift - Py_Size(t1);
+ i = Py_SIZE(ret) - 2*shift - Py_SIZE(t1);
if (i)
- memset(ret->ob_digit + 2*shift + Py_Size(t1), 0,
+ memset(ret->ob_digit + 2*shift + Py_SIZE(t1), 0,
i * sizeof(digit));
/* 3. t2 <- al*bl, and copy into the low digits. */
@@ -2333,23 +2333,23 @@ k_mul(PyLongObject *a, PyLongObject *b)
Py_DECREF(t1);
goto fail;
}
- assert(Py_Size(t2) >= 0);
- assert(Py_Size(t2) <= 2*shift); /* no overlap with high digits */
- memcpy(ret->ob_digit, t2->ob_digit, Py_Size(t2) * sizeof(digit));
+ assert(Py_SIZE(t2) >= 0);
+ assert(Py_SIZE(t2) <= 2*shift); /* no overlap with high digits */
+ memcpy(ret->ob_digit, t2->ob_digit, Py_SIZE(t2) * sizeof(digit));
/* Zero out remaining digits. */
- i = 2*shift - Py_Size(t2); /* number of uninitialized digits */
+ i = 2*shift - Py_SIZE(t2); /* number of uninitialized digits */
if (i)
- memset(ret->ob_digit + Py_Size(t2), 0, i * sizeof(digit));
+ memset(ret->ob_digit + Py_SIZE(t2), 0, i * sizeof(digit));
/* 4 & 5. Subtract ah*bh (t1) and al*bl (t2). We do al*bl first
* because it's fresher in cache.
*/
- i = Py_Size(ret) - shift; /* # digits after shift */
- (void)v_isub(ret->ob_digit + shift, i, t2->ob_digit, Py_Size(t2));
+ i = Py_SIZE(ret) - shift; /* # digits after shift */
+ (void)v_isub(ret->ob_digit + shift, i, t2->ob_digit, Py_SIZE(t2));
Py_DECREF(t2);
- (void)v_isub(ret->ob_digit + shift, i, t1->ob_digit, Py_Size(t1));
+ (void)v_isub(ret->ob_digit + shift, i, t1->ob_digit, Py_SIZE(t1));
Py_DECREF(t1);
/* 6. t3 <- (ah+al)(bh+bl), and add into result. */
@@ -2374,12 +2374,12 @@ k_mul(PyLongObject *a, PyLongObject *b)
Py_DECREF(t1);
Py_DECREF(t2);
if (t3 == NULL) goto fail;
- assert(Py_Size(t3) >= 0);
+ assert(Py_SIZE(t3) >= 0);
/* Add t3. It's not obvious why we can't run out of room here.
* See the (*) comment after this function.
*/
- (void)v_iadd(ret->ob_digit + shift, i, t3->ob_digit, Py_Size(t3));
+ (void)v_iadd(ret->ob_digit + shift, i, t3->ob_digit, Py_SIZE(t3));
Py_DECREF(t3);
return long_normalize(ret);
@@ -2449,8 +2449,8 @@ ah*bh and al*bl too.
static PyLongObject *
k_lopsided_mul(PyLongObject *a, PyLongObject *b)
{
- const Py_ssize_t asize = ABS(Py_Size(a));
- Py_ssize_t bsize = ABS(Py_Size(b));
+ const Py_ssize_t asize = ABS(Py_SIZE(a));
+ Py_ssize_t bsize = ABS(Py_SIZE(b));
Py_ssize_t nbdone; /* # of b digits already multiplied */
PyLongObject *ret;
PyLongObject *bslice = NULL;
@@ -2462,7 +2462,7 @@ k_lopsided_mul(PyLongObject *a, PyLongObject *b)
ret = _PyLong_New(asize + bsize);
if (ret == NULL)
return NULL;
- memset(ret->ob_digit, 0, Py_Size(ret) * sizeof(digit));
+ memset(ret->ob_digit, 0, Py_SIZE(ret) * sizeof(digit));
/* Successive slices of b are copied into bslice. */
bslice = _PyLong_New(asize);
@@ -2477,14 +2477,14 @@ k_lopsided_mul(PyLongObject *a, PyLongObject *b)
/* Multiply the next slice of b by a. */
memcpy(bslice->ob_digit, b->ob_digit + nbdone,
nbtouse * sizeof(digit));
- Py_Size(bslice) = nbtouse;
+ Py_SIZE(bslice) = nbtouse;
product = k_mul(a, bslice);
if (product == NULL)
goto fail;
/* Add into result. */
- (void)v_iadd(ret->ob_digit + nbdone, Py_Size(ret) - nbdone,
- product->ob_digit, Py_Size(product));
+ (void)v_iadd(ret->ob_digit + nbdone, Py_SIZE(ret) - nbdone,
+ product->ob_digit, Py_SIZE(product));
Py_DECREF(product);
bsize -= nbtouse;
@@ -2548,8 +2548,8 @@ l_divmod(PyLongObject *v, PyLongObject *w,
if (long_divrem(v, w, &div, &mod) < 0)
return -1;
- if ((Py_Size(mod) < 0 && Py_Size(w) > 0) ||
- (Py_Size(mod) > 0 && Py_Size(w) < 0)) {
+ if ((Py_SIZE(mod) < 0 && Py_SIZE(w) > 0) ||
+ (Py_SIZE(mod) > 0 && Py_SIZE(w) < 0)) {
PyLongObject *temp;
PyLongObject *one;
temp = (PyLongObject *) long_add(mod, w);
@@ -2737,7 +2737,7 @@ long_pow(PyObject *v, PyObject *w, PyObject *x)
return Py_NotImplemented;
}
- if (Py_Size(b) < 0) { /* if exponent is negative */
+ if (Py_SIZE(b) < 0) { /* if exponent is negative */
if (c) {
PyErr_SetString(PyExc_TypeError, "pow() 2nd argument "
"cannot be negative when 3rd argument specified");
@@ -2756,7 +2756,7 @@ long_pow(PyObject *v, PyObject *w, PyObject *x)
if (c) {
/* if modulus == 0:
raise ValueError() */
- if (Py_Size(c) == 0) {
+ if (Py_SIZE(c) == 0) {
PyErr_SetString(PyExc_ValueError,
"pow() 3rd argument cannot be 0");
goto Error;
@@ -2765,7 +2765,7 @@ long_pow(PyObject *v, PyObject *w, PyObject *x)
/* if modulus < 0:
negativeOutput = True
modulus = -modulus */
- if (Py_Size(c) < 0) {
+ if (Py_SIZE(c) < 0) {
negativeOutput = 1;
temp = (PyLongObject *)_PyLong_Copy(c);
if (temp == NULL)
@@ -2778,7 +2778,7 @@ long_pow(PyObject *v, PyObject *w, PyObject *x)
/* if modulus == 1:
return 0 */
- if ((Py_Size(c) == 1) && (c->ob_digit[0] == 1)) {
+ if ((Py_SIZE(c) == 1) && (c->ob_digit[0] == 1)) {
z = (PyLongObject *)PyLong_FromLong(0L);
goto Done;
}
@@ -2786,7 +2786,7 @@ long_pow(PyObject *v, PyObject *w, PyObject *x)
/* if base < 0:
base = base % modulus
Having the base positive just makes things easier. */
- if (Py_Size(a) < 0) {
+ if (Py_SIZE(a) < 0) {
if (l_divmod(a, c, NULL, &temp) < 0)
goto Error;
Py_DECREF(a);
@@ -2827,10 +2827,10 @@ long_pow(PyObject *v, PyObject *w, PyObject *x)
REDUCE(result) \
}
- if (Py_Size(b) <= FIVEARY_CUTOFF) {
+ if (Py_SIZE(b) <= FIVEARY_CUTOFF) {
/* Left-to-right binary exponentiation (HAC Algorithm 14.79) */
/* http://www.cacr.math.uwaterloo.ca/hac/about/chap14.pdf */
- for (i = Py_Size(b) - 1; i >= 0; --i) {
+ for (i = Py_SIZE(b) - 1; i >= 0; --i) {
digit bi = b->ob_digit[i];
for (j = 1 << (SHIFT-1); j != 0; j >>= 1) {
@@ -2847,7 +2847,7 @@ long_pow(PyObject *v, PyObject *w, PyObject *x)
for (i = 1; i < 32; ++i)
MULT(table[i-1], a, table[i])
- for (i = Py_Size(b) - 1; i >= 0; --i) {
+ for (i = Py_SIZE(b) - 1; i >= 0; --i) {
const digit bi = b->ob_digit[i];
for (j = SHIFT - 5; j >= 0; j -= 5) {
@@ -2860,7 +2860,7 @@ long_pow(PyObject *v, PyObject *w, PyObject *x)
}
}
- if (negativeOutput && (Py_Size(z) != 0)) {
+ if (negativeOutput && (Py_SIZE(z) != 0)) {
temp = (PyLongObject *)long_sub(z, c);
if (temp == NULL)
goto Error;
@@ -2877,7 +2877,7 @@ long_pow(PyObject *v, PyObject *w, PyObject *x)
}
/* fall through */
Done:
- if (Py_Size(b) > FIVEARY_CUTOFF) {
+ if (Py_SIZE(b) > FIVEARY_CUTOFF) {
for (i = 0; i < 32; ++i)
Py_XDECREF(table[i]);
}
@@ -2901,7 +2901,7 @@ long_invert(PyLongObject *v)
Py_DECREF(w);
if (x == NULL)
return NULL;
- Py_Size(x) = -(Py_Size(x));
+ Py_SIZE(x) = -(Py_SIZE(x));
return (PyObject *)x;
}
@@ -2943,7 +2943,7 @@ long_abs(PyLongObject *v)
static int
long_nonzero(PyLongObject *v)
{
- return ABS(Py_Size(v)) != 0;
+ return ABS(Py_SIZE(v)) != 0;
}
static PyObject *
@@ -2957,7 +2957,7 @@ long_rshift(PyLongObject *v, PyLongObject *w)
CONVERT_BINOP((PyObject *)v, (PyObject *)w, &a, &b);
- if (Py_Size(a) < 0) {
+ if (Py_SIZE(a) < 0) {
/* Right shifting negative numbers is harder */
PyLongObject *a1, *a2;
a1 = (PyLongObject *) long_invert(a);
@@ -2981,7 +2981,7 @@ long_rshift(PyLongObject *v, PyLongObject *w)
goto rshift_error;
}
wordshift = shiftby / SHIFT;
- newsize = ABS(Py_Size(a)) - wordshift;
+ newsize = ABS(Py_SIZE(a)) - wordshift;
if (newsize <= 0) {
z = _PyLong_New(0);
Py_DECREF(a);
@@ -2995,8 +2995,8 @@ long_rshift(PyLongObject *v, PyLongObject *w)
z = _PyLong_New(newsize);
if (z == NULL)
goto rshift_error;
- if (Py_Size(a) < 0)
- Py_Size(z) = -(Py_Size(z));
+ if (Py_SIZE(a) < 0)
+ Py_SIZE(z) = -(Py_SIZE(z));
for (i = 0, j = wordshift; i < newsize; i++, j++) {
z->ob_digit[i] = (a->ob_digit[j] >> loshift) & lomask;
if (i+1 < newsize)
@@ -3084,7 +3084,7 @@ long_bitwise(PyLongObject *a,
digit diga, digb;
PyObject *v;
- if (Py_Size(a) < 0) {
+ if (Py_SIZE(a) < 0) {
a = (PyLongObject *) long_invert(a);
if (a == NULL)
return NULL;
@@ -3094,7 +3094,7 @@ long_bitwise(PyLongObject *a,
Py_INCREF(a);
maska = 0;
}
- if (Py_Size(b) < 0) {
+ if (Py_SIZE(b) < 0) {
b = (PyLongObject *) long_invert(b);
if (b == NULL) {
Py_DECREF(a);
@@ -3143,8 +3143,8 @@ long_bitwise(PyLongObject *a,
whose length should be ignored.
*/
- size_a = Py_Size(a);
- size_b = Py_Size(b);
+ size_a = Py_SIZE(a);
+ size_b = Py_SIZE(b);
size_z = op == '&'
? (maska
? size_b
@@ -3351,7 +3351,7 @@ long_subtype_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
if (tmp == NULL)
return NULL;
assert(PyLong_CheckExact(tmp));
- n = Py_Size(tmp);
+ n = Py_SIZE(tmp);
if (n < 0)
n = -n;
newobj = (PyLongObject *)type->tp_alloc(type, n);
@@ -3360,7 +3360,7 @@ long_subtype_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
return NULL;
}
assert(PyLong_Check(newobj));
- Py_Size(newobj) = Py_Size(tmp);
+ Py_SIZE(newobj) = Py_SIZE(tmp);
for (i = 0; i < n; i++)
newobj->ob_digit[i] = tmp->ob_digit[i];
Py_DECREF(tmp);