Re: [Python-ideas] Floating point contexts in Python core

On 12/10/12 11:04, Mark Adam wrote:
On Thu, Oct 11, 2012 at 6:35 AM, Steven D'Aprano<steve@pearwood.info> wrote:
On 11/10/12 16:45, Greg Ewing wrote:
Are you sure there would be any point in this? People who specifically *want* base-2 floats are probably quite happy with the current float type, and wouldn't appreciate having it slowed down, even by a small amount.
I would gladly give up a small amount of speed for better control over floats, such as whether 1/0.0 raised an exception or returned infinity.
Umm, you would be giving up a *lot* of speed. Native floating point happens right in the processor, so if you want special behavior, you'd have to take the floating point out of hardware and into "user space".
Any half-decent processor supports the IEEE-754 standard. If it doesn't, it's broken by design. Even in user-space, you're not giving up that much speed in practical terms, at least not for my needs. The new decimal module in Python 3.3 is less than a factor of 10 times slower than Python's floats, which makes it pretty much instantaneous to my mind :) numpy supports configurable numeric contexts, and I don't hear that many complaints that numpy is slower than standard Python. -- Steven
mark

On 12.10.2012 03:03, Steven D'Aprano wrote:
Any half-decent processor supports the IEEE-754 standard. If it doesn't, it's broken by design.
Even in user-space, you're not giving up that much speed in practical terms, at least not for my needs. The new decimal module in Python 3.3 is less than a factor of 10 times slower than Python's floats, which makes it pretty much instantaneous to my mind :)
I will not have any effect on the flops rate. The other stuff the interpreter must do when using floats (allocating and deleting float objects on the heap, initializing new objects, etc.) will dominate the run-time performance. Even a simple check for divide-by-zero (as we have today) will be more expensive than using another numerical context inside the hardware. Sturla

I would gladly give up a small amount of speed for better control over floats, such as whether 1/0.0 raised an exception or returned infinity.
Umm, you would be giving up a *lot* of speed. Native floating point happens right in the processor, so if you want special behavior, you'd have to take the floating point out of hardware and into "user space".
Even in user-space, you're not giving up that much speed in practical terms, at least not for my needs. The new decimal module in Python 3.3 is less than a factor of 10 times slower than Python's floats, which makes it pretty much instantaneous to my mind :)
Hmm, well, if it's only that much slower, then we should implement Rationals and get rid of the issue altogether. Mark
participants (3)
-
Mark Adam
-
Steven D'Aprano
-
Sturla Molden