JuliaCon 2022 (Times are UTC)

Extending PyJL to Translate Python Libraries to Julia
07-27, 19:30–20:00 (UTC), Blue

Many new high-level programming languages have emerged in recent years. Julia is one of these languages, that offers the speed of C, the macro capabilities of Lisp, and the user-friendliness of Python. However, its library set is still reduced when compared to languages, such as Python. We propose extending PyJL, an open source transpilation tool, to speedup the conversion of libraries to Julia.


PyJL is part of the Py2Many transpiler, which is a rule-based transpilation tool. PyJL builds upon Py2Many to translate Python source code to Julia. Parsing is performed through Python's ast module, which generates an Abstract Syntax Tree. Then, several intermediate transformations convert the input Python source code into Julia source code.

In terms of our results, we managed to translate two commonly used benchmarks:
1. The N-Body problem, achieving a speedup of 19.5x when compared to Python, after adding only one type hint
2. An implementation of the Binary Trees benchmark to test Garbage Collection, which resulted in 8.6x faster execution time without requiring any user intervention

The current major limitations of PyJL are type inference and mapping Python's OO paradigm to Julia. Regarding type inference, PyJL requires type hints in function arguments and return types, and we are currently integrating pytype, a type inference mechanism, to verify the soundness of type hints. Regarding the OO paradigm, PyJL currently maps Julia's classes, including class constructors, and single inheritance to Julia. However, Python's special methods, such as __repr__ or __str__ still require proper translation.

Although the development of our transpilation tool is still at an early stage, our preliminary results show that the transpiler generates human-readable code that can achieve high performance with few changes to the generated source code.

See also: Extended Abstract (407.7 KB)

I am a Master Thesis student at Instituto Superior Técnico and I am currently working on a transpiler to translate Python libraries into Julia. I also have experience in Java, Python, TypeScript, C, a hint of Haskell and, most recently, Julia, which surprised me for how fast and simple programming can be.
Besides my programming activities, I am also a fan of photography, sports and writing.