Comments (9)
I am not the author of Nuitka, but I can say that it is next to impossible to help you with the information you give. You should try progressively trimming down your program. After each simplification, you compare execution times again, and if the Nuitka-compiled version is still slower than the pure Python version, you continue the simplification. Otherwise, you recover what you just simplified and try simplifying differently, so that you pin point exactly what is the problematic code. Repeat until you have something small enough and self-contained to be included as text in the issue as part of completing the entire issue template that you avoided completing so far.
Alternatively, you might be able to find someone to do that for you for a price. I don't know whether @kayhayen (the main author of Nuitka) does this kind of work as part of his commercial offerings (https://nuitka.net/doc/commercial.html).
PS: not all code is supposed to go significantly faster. For example if your code calls a lot of functions from an external library which is already mostly implemented in C (e.g. numpy), it will not go much faster by compiling it using Nuitka. That said, it should probably not go slower, so your issue could be worth investigating nevertheless.
from nuitka.
I am trying to run a big code by using Python and Nuitka.
Run time for the code using python is 13 secs, however with Nuitka it takes about 14-15 secs.
It is expected that the code should run fast with Nuitka.
Please guide me what should be done in this case
from nuitka.
@gdementen Thank you for the information. I can try simplifying the code to check where the problem is exactly, hopefully that works.
I also have another question. My code does call quite a few functions from external library, so if I call those functions through a different file suppose function.py, and include the code in a different file called main.py, then can I run both the file using nuitka? Is it possilbe to do so?
Will that help in running the code faster?
from nuitka.
You should read the manual. There are many options. Some of them compile everything, including all dependent modules.
from nuitka.
okay, I will go through it. Can you also explain me the use of standalone and clang?
from nuitka.
This is not a personal support thread, sorry. If you have more questions that the manual does not answer, you can create more issues, but if not, I am likely just deleting them.
from nuitka.
Hello, so I did try running a very simple python code with Nuitka.
modules.py
def add(a, b):
return a + b
def subtract(a, b):
return a - b
class Calculator:
def multiply(self, a, b):
return a * b
def divide(self, a, b):
if b == 0:
raise ValueError("Cannot divide by zero")
return a / b
This was the code for modules.py
and
main.py
from modules import add, subtract, Calculator
def main():
x = 10
y = 5
print(f"Addition: {add(x, y)}")
print(f"Subtraction: {subtract(x, y)}")
calc = Calculator()
print(f"Multiplication: {calc.multiply(x, y)}")
print(f"Division: {calc.divide(x, y)}")
if name == "main":
main()
This is the code for main.py
When I compiled it with python3 it took hardly 0.028secs
however with Nuitka it took 4 secs.
Can you please explain what is going wrong? why is nutika taking so long to run? what should be done in this case?
from nuitka.
I tried with both clang and gcc, the time required is almost sane for both
from nuitka.
I have a hard time believing the compiled executable for that code would take 4 seconds to RUN, so I suppose you misunderstand how both Python and Nuitka work. Python is an interpreted language, so when you execute a .py file, it is not compiled to binary code but rather executed step by step.
On the other hand, when using Nuitka, it is compiled. That compilation step is very expensive (but only needs to happen once) but then execution time is usually lower. So you trade-off compilation time for easier distribution (what most current users of Nuitka care about) and somewhat faster execution time. In short you should compare Python execution time to the Nuitka-created binary execution time, not the time it took Nuitka to create that binary.
Now if the binary is actually taking 4 seconds to execute (not create!), then there might effectively be a problem somewhere (not necessarily in Nuitka -- it might also be your antivirus being annoyingly slow). IF that is the case AND you have confirmed it is not an antivirus problem, feel free to reopen another issue giving all the information asked by the issue template (without the full issue template filled we cannot help you).
@kayhayen In any case, I feel the current issue should be closed.
from nuitka.
Related Issues (20)
- Bug with --windows-console-mode=attach HOT 4
- UnicodeDecodeError: 'cp932' codec can't decode byte 0x85 in position 56546: illegal multibyte sequence HOT 7
- Handle exit signal with --windows-console-mode=attach HOT 3
- Pandera's check doesn't work after bundling HOT 4
- Forward slash character in path incorrectly rejected on Windows HOT 5
- Error, failed to evaluate condition 'no_docstrings and no_asserts' in this context, exception was ''NuitkaPluginAntiBloat' object has no attribute 'decideAssertions' HOT 1
- [BUG]UnicodeDecodeError on nuitka 2.4 HOT 21
- Error in using nuitka-hints.py to perform hints compilation. Any compatible problem between nuitka 2.4.4 and nuitka-hints.py? HOT 1
- Data files missing for Perfetto module HOT 1
- [BUG] --jobs options with negative values is not working on nuitka 2.4 HOT 3
- use onefile failed to run, how to check this error? HOT 1
- [Question] Does Nuitka support multiprocessing? (Yes) HOT 2
- [BUG] Can't import python native ssl module (ImportError) HOT 2
- Can't run the compiled spacy application: No module named 'spacy.lexeme' HOT 5
- cannot import gssapi library properly
- `anyio`'s `to_process.run_sync` breaks after compilation by nuitka HOT 3
- AttributeError: 'nuitka_resource_reader_files' object has no attribute 'suffix' HOT 2
- Multicore execution - Do Binaries compiled by Nuitka, run concurrently unlike Phyton? HOT 2
- Please add Anti injection to the Nutika exe to prevent dlls to be injected into it like pyshell and more HOT 2
- Nuitka Module Importing External Numba .so file
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from nuitka.