I think I have to switch from using Julia to Python/Numpy. I know. I’m going the wrong way! Still, it’s become increasing apparent it’s the right thing to do.
I know Julia much better than Python/Numpy, but Julia isn’t supported by or is a huge PITA to get working in the tools we use at work.
More generally, probably you could explain better what you mean by “moving to”. You want to translate all your Julia code to Numpy? Or just learn numpy given a Julia experience?
Probably here you will get more tips on how to better integrate your Julia development workflow with the Python packages (or the C++ packages that are in that Python package).
We use numpy and Julia extensively, here are a few things we’ve found:
PyJulia and PyCall are pretty great for interop, so you can keep using your existing code
It’s really easy to pass arrays, Dicts, and scalar values like strings, numbers, etc. between the two. It’s harder, but doable, to pass more complex data structures. So try to keep any interfaces between the two limited to those data types.
Julia has fast for loops, python/numpy doesn’t. So you’ll want to eliminate those as much as possible and lean heavily on vectorization
Numpy doesn’t really have loop fusion, so you’ll need to be more careful monitoring memory usage
That’s about it. For the most part, translation is relatively straightforward.
“Moving to” means, having Julia knowledge/code and probably a REPL open while prototyping but moving all that code/knowledge to python/numpy for the final product. Eventually not using Julia at all, and just writing python/numpy.
Best case scenario would be a source-to-source translator or julia->python compiler source. Next best is a good set of cheatsheets/tutorials/experiences on translating/rewriting julia to numpy The one I posted seems pretty good.
This seems to be the biggest difference between the numpy way of doing things and the Julia way. Although more recent Julia code is much more vectorized and closer to numpy in this way.
Translation should not be particularly difficult in general. It will be harder, depending on the code, to retain the performance, if the code is not easily vectorized. Perhaps you will finally have to learn some C, C++, or Numba, PyPy, to code some specific parts of the code that are more important for performance.
(as a side note, that particular package you mention above is just a front-end to a series of C++ libraries. A cool project could be to write that same front-end in Julia and have the best of both worlds).
@Orbots I don’t know if you’re still open to being convinced, but either way it would be helpful for us to know what is missing for you in Julia if you’re willing to talk about it.
I was not assuming anything, it was just a remark about something to be considered in the migration process. Sorry if that felt differently in any way.
The nice thing about Julia is that it’s roughly equally fast whether you use vectorized or non-vectorized code. So if you’re porting Julia code to Python, one good option is to go through, find any for loops, and rewrite them using vectorization/broadcasting instead. Then you can almost copy & paste that code to python with minor modifications (I’ve done it!), you’ll just need to get rid of the dots for broadcasting.