M
Modular12mo ago
denden

Will imported python modules eventually be compiled by Mojo instead of relying on the python env?

I understand that currently imported python packages run on the CPython interpreter which will require a compiled Mojo program to run with the same python environment in which it was complied (same installed packages etc). Will the need for this go away once Mojo is a true superset of Python. IOW, will the imported python module get complied just as if the Python code was written directly in the Mojo program?
6 Replies
boxed
boxed12mo ago
Just being a syntactic superset of Python isn't nearly enough. Part of the reason to target Python is the huge ecosystem of libs that are not python, most importantly C, C++ and Fortran libs with good python wrappers. Just compiling all the Python code (if that's even possible) wouldn't really help with that. Interop is the only way. Also note that "syntactic superset" doesn't neccessarily mean it will run all python code the same ;P
denden
denden12mo ago
Thanks for the reply. I was sure Chris Lattner said in an interview that if you past pure python straight into Mojo, you should get around a 10X performance boost because of compilation. If that is the case, as long as the python package does not use other languages, then it should be able to compile it right? that being said...maybe there is no good way to detect if it is a pure python package though? I would hope there isn't a dramatic difference though...could you give an example of this?
boxed
boxed12mo ago
Mojo is a looooong way from the goal of syntactic superset though. For example classes, and keyword arguments aren't supported. I don't think I have any python code I've written in the last 10 years that can run unmodified in mojo :P meta classes for example are quite fiddly.. and walking the mro is also special... looking at local variables
denden
denden12mo ago
Yes, I do realize it is far from complete currently, but it definitely one of the primary goals!
boxed
boxed12mo ago
I would guess it's more of an aspirational long goal. There are a lot of big wins that can be had by not being straight python that they should target first. But ease of porting is a big goal yea, much bigger and important than syntactic superset.
BmoVibe
BmoVibe12mo ago
I feel like once it becomes open source, we will see a rise in developers who can't sit around and wait for compatibility. That's just my opinion.
Want results from more Discord servers?
Add your server