r/learnpython • u/Dzhama_Omarov • Jan 03 '25
Are extensions like Cython really turn Python into a compiled language?
I was chatting with chatGPT the other day and he told me about compiled and interpreted languages. He’s also told me about extensions like Cython that aim to make your Python code compiled. So, I was wondering if they really give your code the benefits of compiled languages or they work in a different way
P.s. I apologize in advance if my question makes no sense. I’ve never dealt with compiled languages and I have vague knowledge about them
0
Upvotes
17
u/eleqtriq Jan 03 '25
I like that you called ChatGPT “he” 😂
Cython is an extension, but it’s really a superset of Python. It’s still requires the CPython runtime. It’s best used to make modules IMHO, that can be imported into Python and used. To make true use of it, you also need to use type annotations, otherwise the benefits are “meh”.
By using Cython, you’re not going to get an executable.
In my opinion, if you’re looking at Cython, you might as well use another language. I feel the scope of good use cases are narrow, such as graphics processing where an already existing library doesn’t exist.