Python Forum
what is speed of different functions of math library?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
what is speed of different functions of math library?
#1
what is execution time (speed) of math functions like isqrt(), exp(x), log(), log10() etc.?
Reply
#2
you understand this depends on particular system you run your code on, right?
care to elaborate what you are after?
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply
#3
You can do the check by yourself:
Windows PowerShell
Copyright (C) Microsoft Corporation. Alle Rechte vorbehalten.

Lernen Sie das neue plattformübergreifende PowerShell kennen – https://aka.ms/pscore6

PS C:\Users\Admin> ipython.exe
Python 3.8.2 (tags/v3.8.2:7b3ab59, Feb 25 2020, 23:03:10) [MSC v.1916 64 bit (AMD64)]
Type 'copyright', 'credits' or 'license' for more information
IPython 7.13.0 -- An enhanced Interactive Python. Type '?' for help.

In [1]: import math

In [2]: isqrt = math.isqrt

In [3]: %timeit isqrt(1)
76.5 ns ± 4.86 ns per loop (mean ± std. dev. of 7 runs, 10000000 loops each)

In [4]:
You could use the %timeit macro in IPython3.
I have done the assignment of isqrt to save lookup time.

Of course the results differs between Linux/Windows/Mac and CPU +cache.
You won't get always the same results, because in the background is also much happening.
Almost dead, but too lazy to die: https://sourceserver.info
All humans together. We don't need politicians!
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020