Kaydet (Commit) ba71a247 authored tarafından Guido van Rossum's avatar Guido van Rossum

Simple optimization by Christian Tismer, who gives credit to Lenny

Kneler for reporting this issue: long_mult() is faster when the
smaller argument is on the left.  Swap the arguments accordingly.
üst 2516b39d
...@@ -1223,6 +1223,15 @@ long_mul(a, b) ...@@ -1223,6 +1223,15 @@ long_mul(a, b)
size_a = ABS(a->ob_size); size_a = ABS(a->ob_size);
size_b = ABS(b->ob_size); size_b = ABS(b->ob_size);
if (size_a > size_b) {
/* we are faster with the small object on the left */
int hold_sa = size_a;
PyLongObject *hold_a = a;
size_a = size_b;
size_b = hold_sa;
a = b;
b = hold_a;
}
z = _PyLong_New(size_a + size_b); z = _PyLong_New(size_a + size_b);
if (z == NULL) if (z == NULL)
return NULL; return NULL;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment