[Numpy-discussion] Re: numpy, overflow, inf, ieee, and rich , comparison
Huaiyu Zhu
hzhu at users.sourceforge.net
Thu Oct 26 14:01:48 EDT 2000
- Previous message (by thread): [Numpy-discussion] Re: numpy, overflow, inf, ieee, and rich , comparison
- Next message (by thread): [Numpy-discussion] Re: numpy, overflow, inf, ieee, and rich , comparison
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
On Thu, 26 Oct 2000 07:16:06 GMT, Donald O'Donnell <donod at home.com> wrote:
>
>What I think some people are loosing sight of, is that the
>underlying hardware instruction set of most computers
>contains an integer division instruction which results in a
>quotient and a remainder (which, BTW Alex, implies that it
>doesn't cost any more to get both even if all you want is just
>the quotient or just the remainder), which is usually at least
>an order of magnitude faster than a hardware floating point
>division; and on some computers which lack floating point
>hardware, a software generated floating point result could
>take several orders of magnitude longer to compute.
>
>The compiled C code underlying a Python integer division makes
>use of this fast hardware integer division instruction. If
>Python were changed so that all integer divisions were done in
>floating point, we would loose the ability to make use of this
>fast hardware divide instruction. This could have a severe
>negative impact on some compute intensive (Numpy?) programs.
A little test result. Doing a+a one million times takes 2.05sec for a==2.2,
and 1.82sec for a==22. That's about 9/8 ratio.
For a/a the time ratio becomes 2.180/ 2.040, or about 16/15.
Doesn't look like an order of magnitude to me.
Huaiyu
--
from profile import run
from operator import div
def test(a):map(div, a, a)
a = [22]*1000000; run("test(a)")
a = [2.2]*1000000; run("test(a)")
- Previous message (by thread): [Numpy-discussion] Re: numpy, overflow, inf, ieee, and rich , comparison
- Next message (by thread): [Numpy-discussion] Re: numpy, overflow, inf, ieee, and rich , comparison
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the Python-list
mailing list