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
4
u/billsil Jan 03 '25
Python code is compiled to pyc and then interpreted.
Cython is a separate language that's similar to python, but more like C, but really different than both and lets you compile Python to C. You can then import a Python module into a larger Python program or larger C program. Honestly, unless you get good at it and/or C, you'll probably find it slows down your code for a lot of work. I prefer numpy's f2py to convert Fortran code.