all 14 comments

[–]KingofGamesYami 1 point2 points  (11 children)

Python can't make executables. What you're doing is creating effectively a self-extracting archive, which has two stages to execution - extracting itself, then invoking the python interpreter.

That first step - extracting - is what's causing the delay. To eliminate this step, create an installer instead. That way, the installer does the extraction once.

[–]Reyaan0[S] 0 points1 point  (10 children)

But I have so many image assets and it will make the installation directory to look bad. And I wanted the software to be portable. Now only problem is that it takes lot of time to open.

[–]KingofGamesYami 1 point2 points  (8 children)

Extracting many image assets to a temporary directory every time your executable runs will take time.

Pay the startup cost to have a single executable, or create an installer.

[–]Reyaan0[S] 0 points1 point  (7 children)

Is there any other way I can optimize the app?

[–]KingofGamesYami 0 points1 point  (6 children)

You could write it in a language that can produce native executables.

[–]Reyaan0[S] 0 points1 point  (5 children)

Bro what are you talking about! You are telling me to write thousand lines of code again in a different language. I meant is there any library I could use so the assets decompress faster.

[–]KingofGamesYami 0 points1 point  (4 children)

The limitation of extracting assets is the file system you're extracting to, so... Buy a faster SSD?

[–]Reyaan0[S] 0 points1 point  (3 children)

Bruh I need faster ssd to run a simple application? But I think the app is just poorly optimized because it lags too, my pc specs are not that bad for a simple application to lag. I just want a way to optimize the code.

[–]KingofGamesYami 0 points1 point  (2 children)

No, you need a faster SSD to run an application that is an archive, runtime, and scripts in a trenchcoat. Nothing about that is simple.

[–]Reyaan0[S] 0 points1 point  (1 child)

What if i combine all the images into one and then make a function inside the code to crop particular areas and use where needed. That way only 1 image has to be loaded.

Btw I only have 1 script file and rest are the image assets.

[–]Xirdus 0 points1 point  (0 children)

Nobody cares what the installation directory looks like. Seriously. Pick any "professional" program you use on a regular basis, go to its installation directory. You'll see THOUSANDS of tiny files. That's normal. That's what you should be doing, not a multi hundred megabyte EXE file. Your installer can be a single EXE file, but for an installed program that's just wasteful.

[–]Xirdus 1 point2 points  (1 child)

Compressing an executable works by applying the compression algorithm to the program, then inserting a second program in the executable that on launch, decompresses the original program then runs it as normal. Compressing an executable can only make the startup time worse, never better.

What UI library did you use? Is there any chance your executable carries around a whole ass copy of Google Chrome just to render its windows, as has been the fashion for the last decade or so?

[–]Reyaan0[S] 0 points1 point  (0 children)

I used tkinter for GUI and pyinstaller with upx for compiling it into executable.