Nuitka: nuitka binaries slow performance with Python3 in-place string add
Nuitka version:
0.6.0rc4
Python: 3.6.6 (default, Sep 12 2018, 18:26:19)
Executable: /usr/bin/python3
OS: Linux
Arch: x86_64
Installed via: apt
Greetings,
Really love this project. Thanks for all your hard work on it. My nuitka binaries generally perform really well, even for complex projects. The one exception is when I implement code that generates a large volume of random numbers. The code below is much slower in a nuitka build when compared to running it in the python3 interpreter:
chars = []
for i in range(256):
chars += [chr(i)]
wrapper = ""
for i in range(10000000):
wrapper += random.choice(chars)
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Comments: 21 (12 by maintainers)
Thank you again! I can see how creating strings (which are immutable in python) would be a waste. I re-factored the code to use lists rather than strings, with a final
.join()at the end, and it is indeed much faster in nuitka. It now looks like this: