question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Nuitka makes plus and minus much slower

See original GitHub issue

I’ve tried to compile a performance test using nuitka 0.6.13rc2 in order to again investigate in what extent can Nuitka speed up a python program. It showed Nuitka made the plus and minus operation 15%~20% slower than before, but Nuitka also speed up multiply operation about 60% that’s incredible! Besides, I’m also curious about using which compiler would make program faster msvc or mingw64?

Platform: Windows CPU: Ryzen7 1700 RAM: DDR4-3200*2 Python: 3.8.7 (x64) Nuitka: 0.6.13rc2

Before: 2021-02-13 225000

Compiler command (msvc): nuitka --msvc=MSVC --windows-disable-console --standalone --show-progress --output-dir=C:\Users\home\Desktop\1 C:\Users\home\PycharmProjects\speedtest\venv\main.py 2021-02-13 224745

Compiler command (mingw64): nuitka --mingw64 --windows-disable-console --standalone --show-progress --output-dir=C:\Users\home\Desktop\1 C:\Users\home\PycharmProjects\speedtest\venv\main.py 2021-02-13 224824

Code:

import time
import os

def plus():
    a = 0
    for x in range(100000000):
        a += 1

def minus():
    a = 100000000
    for x in range(100000000):
        a -= 1

def multiply():
    a = 1
    for x in range(100000000):
        a *= 1.00000003

def divide():
    a = 1000000000
    for x in range(100000000):
        a /= 1.00000003

if __name__ == '__main__':
    s = time.time()
    plus()
    e = time.time()
    print('Plus:',round(100000000/(e-s)/1000000,2),'M/s')
    s = time.time()
    minus()
    e = time.time()
    print('Minus:',round(100000000/(e-s)/1000000,2),'M/s')
    s = time.time()
    multiply()
    e = time.time()
    print('Multiply:',round(100000000/(e-s)/1000000,2),'M/s')
    s = time.time()
    divide()
    e = time.time()
    print('Divide:',round(100000000/(e-s)/1000000,2),'M/s')
    os.system('pause')

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:35 (30 by maintainers)

github_iconTop GitHub Comments

4reactions
kayhayencommented, Mar 19, 2021

Part of the 0.6.13 release.

Appyling the lessons learned to binary operations for consistency also, is for 0.6.14. I will keep this open, because I want to work on the other things mentioned in that cycle potentially too.

3reactions
kayhayencommented, May 25, 2021

The improvement for 3.9 makes this about 20% faster. For 0.6.16 we will see what Nuitka Python can do. With static linking rather than DLL linkage, I expect a huge gain again.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Nuitka: a Python compiler | Hacker News
I built a small app that retrieves data from a remote server, builds a summary and then pushes it to a local html...
Read more >
Bountysource
Nuitka makes plus and minus much slower. ... Coming soon: A brand new website interface for an even better experience!
Read more >
Nuitka the python compiler - YouTube
[EuroPython 2012] K Haye - 4 JULY 2012 in "Track Ravioli"
Read more >
Why is the power operator much slower than multiplication in ...
Nuitka is a Python compiler that outputs a binary file (IIRC). ... negative, 0.5 power (square root) to invoke faster routines.
Read more >
Why Python is Slow: Looking Under the Hood
When I teach courses on Python for scientific computing, I make this point ... Python is slower than Fortran and C for a...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found