A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from http://mail.python.org/pipermail/python-dev/2000-April/003194.html below:

[Python-Dev] Long Multiplication is not commutative.

[Python-Dev] Long Multiplication is not commutative. [Python-Dev] Long Multiplication is not commutative.Guido van Rossum guido@python.org
Thu, 06 Apr 2000 17:32:36 -0400
> This buddy...
> 
> >>> def ifact3(n) :
> ...  p = 1L
> ...  for i in range(1,n+1) :
> ...    p = i*p
> ...  return p
> 
> performs better by a factor of 1.8 than this one:
> 
> >>> def ifact1(n) :
> ...  p = 1L
> ...  for i in range(1,n+1) :
> ...    p = p*i
> ...  return p
> 
> The analysis of this behavior is quite simple if you look at the
> implementation of long_mult. If the left operand is big and the
> right is small, there are much more carry operations performed,
> together with more loop overhead.
> Swapping the multiplicands would be a 5 line patch.
> Should I submit it?

Yes, go for it.  I would appreciate a bunch of new test cases that
exercise the new path through the code, too...

--Guido van Rossum (home page: http://www.python.org/~guido/)



RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4