-
-
Notifications
You must be signed in to change notification settings - Fork 480
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
65x penalty in performance for using float instead of RealNumber #11332
Comments
comment:1
It's a bit worse:
125 loops, best of 3: 7.88 ms per loop while
625 loops, best of 3: 48.3 µs per loop so the ratio is rather around 150x. |
comment:2
note that "float" is the standard python float type, whereas RealNumber is a preferred type for sage. Furthermore, "exp" is a general sage function that can do all kinds of "exponentiation" (symbolic, numeric etc.), and that incurs overhead. Apparently a particularly bad one for "float" types. Setting the base line:
Using python's own "exp" is the fastest:
You can shave off some time from the RealNumber one too by calling a method specific for it. It's slower, but RealNumber has much more functionality (also multiprecision)
RDF is supposed to be Sage's version of "double precision floats" and is indeed comparable:
If you don't mind a float, math.exp seems to receive a fairly efficiently coerced float from either RealNumber or RDF
It would be nice if the generic "exp" would find a bit faster codepaths for some of these types, but I wouldn't consider the current behaviour a "defect". |
comment:8
Fixed?
|
comment:9
Replying to @mezzarobba:
Half
just 30x slower. Better than the 65x that was reported for the difference between |
comment:10
92x on my system:
|
comment:11
Wait, what exactly are we trying to measure? I thought this ticket was about the overhead of |
comment:12
Agreed that it is not exactly the same issue... but still there is a problem for |
comment:13
I think there was progress from I don't think you can get better than a few µs for symbolic |
Reviewer: Maarten Derickx |
comment:14
I agree that the original problem is fixed. |
The function random() returns a "float", but 1.0*random() is a "RealNumber". The following code:
takes 5.24 seconds, while
takes 0.08
Component: symbolics
Keywords: float, RealNumber
Reviewer: Maarten Derickx
Issue created by migration from https://trac.sagemath.org/ticket/11332
The text was updated successfully, but these errors were encountered: