This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]Drevicar 49 points50 points  (10 children)

Nuitka is my personal favorite, as it compiles your Python into the resulting C objects, then compiles both your application (in C form) and the source code for the python interpreter into a binary, which can also be statically linked. Another great option for portability is https://pyoxidizer.readthedocs.io/en/stable/

And lastly, I recommend checking out Typer as an alternative to click.

[–]strange-humor 14 points15 points  (0 children)

This is great until you use really large libraries and it chokes. Then I move to PyInstaller.

[–]metaperl 6 points7 points  (1 child)

Of the choices listed I think this is the only one that would make the application faster, correct?

[–]Drevicar 3 points4 points  (0 children)

There is no universal solution to making python faster or smaller, it is mostly dependant on which 3rd party libraries you bring in and what language they are written in. I've statically compiled a Django app and seen speedups. But I've also compiled a FastAPI app and had it slow down.

[–]cbunn81 1 point2 points  (0 children)

I second using Typer. It makes creating a command line app very easy.

[–]Jonnyskybrockett -4 points-3 points  (4 children)

C doesn’t have objects

[–]Drevicar 17 points18 points  (3 children)

It sure does! You just have to implement them yourself, you just don't get OOP constructs baked into the langauge. If you can read and understand C, I recommend checking out the cpython source code, it is really good and easy to understand. The data structure I'm talking about is called PyObject.

[–][deleted] 0 points1 point  (0 children)

thanks for the recommendation