# \[ANN\] Announcing Jl2Py.jl: A minimal Julia-to-Python transpiler

**URL:** https://discourse.julialang.org/t/ann-announcing-jl2py-jl-a-minimal-julia-to-python-transpiler/84406
**Category:** Package Announcements
**Tags:** python, pythoncall
**Created:** [July 18, 2022, 1:33pm UTC](https://discourse.julialang.org/t/ann-announcing-jl2py-jl-a-minimal-julia-to-python-transpiler/84406 "2022-07-18T13:33:06Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![lucifer1004](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lucifer1004/32/22311_2.png) [@lucifer1004](https://discourse.julialang.org/u/lucifer1004)
#### Post date: [July 18, 2022, 1:33pm UTC](https://discourse.julialang.org/t/ann-announcing-jl2py-jl-a-minimal-julia-to-python-transpiler/84406/1 "2022-07-18T13:33:06Z")

</div>

[Jl2Py.jl](https://github.com/lucifer1004/Jl2Py.jl) is a minimal package (roughly 400 LOC at the moment) that transpiles Julia code to Python.

Example (from [LeetCode.jl](https://github.com/JuliaCN/LeetCode.jl/blob/master/src/problems/1.two-sum.jl)):

```julia
function two_sum(nums::Vector{Int}, target::Int)::Union{Nothing,Tuple{Int,Int}}
    seen = Dict{Int,Int}()
    for (i, n) in enumerate(nums)
        m = target - n
        if haskey(seen, m)
            return seen[m], i
        else
            seen[n] = i
        end
    end
end

```

And the converted Python version:

```python
def two_sum(nums: List[int], target: int, /) -> Union[None, Tuple[int, int]]:
    seen = {}
    for (i, n) in enumerate(nums):
        m = target - n
        if haskey(seen, m):
            return (seen[m], i)
        else:
            seen[n] = i

```

Note that some of Julia’s built-in functions need to be polyfilled, e.g., `haskey()` in the above example.

The package is kinda opinionated since there are many cases where a perfect equivalence cannot be found. I am happy to hear from the community more advice on where to improve.
