Sublime Forum

Why is the startup of Sublime Text so small

#1

I wonder why the startup time of sublime text is that small. (0.13 s at my side)
I already wrote some applications with python and generated executable from it (with pyinstaller) but the startup time is not comparable.
I assume that Sublime Text uses a different approach for the startup than pyinstaller and also the application design is different.
So i would be interested how this is done and what i could learn from this to improve the startup time of my applications?

1 Like

#2

Because Sublime is a C or C++ application optimized to do so. Straight C or C++ is going to be faster than Python. Python has overhead to parse in files, convert them to byte code, and then execute that code through its framework; though Python will cache your compiled Python code on first run, so it is usually faster to load on the second time.

With PyInstaller there is a little more overhead especially on the first load. PyInstaller bundles your Python code and all the necessary Python binaries and libraries. It then unpacks those from your executable to a temporary folder on execution, and then runs an instance of the Python bundled with the app, that then loads up your application.

Python is slower than well written C and C++. Python’s threading also is generally limited to 1 thread. Even when you are threading in Python, it is switching tasks only executing a single thread at a time due to the GIL.

Sublime Text starts without loading any of its Python plugins, so it starts fairly fast. Then it begins setting up the Python environment and loading plugins in the background. It’s going to be faster.

I use Python for a lot of general purpose applications, but there are certain tasks that are just going to be slower in Python due to the overhead. It is also why Python even supports modules written in C. Sometimes when you need speed, Python isn’t going to cut it. In a Python C module, I believe you can also release the GIL threading constraints.

If Sublime was written in pure Python, it would not be anywhere near as fast not matter how well it was coded. Python is great, but it is all about using the right tool for the right job.

There is nothing wrong with writing applications in Python, and I often do it because the tradeoff for rapid development in Python outweighs the performance cons (and also because I really enjoy writing in Python). But sometimes, I just need speed, so I write in C or something native to the OS that is going to be fastest.

14 Likes