# Python Implemention in Julia

**URL:** <https://discourse.julialang.org/t/python-implemention-in-julia/79522>\
**Category:** Offtopic\
**Tags:** question\
**Created:** [April 15, 2022, 8:23am UTC](https://discourse.julialang.org/t/python-implemention-in-julia/79522 "2022-04-15T08:23:54Z")\
**Posts on this page:** 7\
**Page:** 2

<div class="post-metadata">

**Author:** ![goerch](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/goerch/32/29122_2.png) [@goerch](https://discourse.julialang.org/u/goerch)\
**Post date:** [April 15, 2022, 8:15pm UTC](https://discourse.julialang.org/t/python-implemention-in-julia/79522/21 "2022-04-15T20:15:46Z")

</div>

> [@jar1](#):
>
> RustPython has about 90kloc of Rust.

Another interesting [data point](https://github.com/RustPython/RustPython/graphs/contributors): 3-4 main contributors working for around 3-4 years.

---

<div class="post-metadata">

**Author:** ![stevengj](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stevengj/32/71_2.png) [@stevengj](https://discourse.julialang.org/u/stevengj)\
**Post date:** [April 15, 2022, 9:30pm UTC](https://discourse.julialang.org/t/python-implemention-in-julia/79522/22 "2022-04-15T21:30:42Z")

</div>

> [@jar1](#):
>
> Having another implementation of Python can be useful, e.g.
> 
> > RustPython can be embedded into Rust programs to use Python as a scripting language for your application, or it can be compiled to WebAssembly in order to run Python in the browser.

CPython can [also be embedded](https://docs.python.org/3/extending/embedding.html) in other programs, and that’s precisely what PyCall and PythonCall currently do.

Compiling to WebAssembly is another VM situation.

---

<div class="post-metadata">

**Author:** ![ImreSamu](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/imresamu/32/20677_2.png) [@ImreSamu](https://discourse.julialang.org/u/ImreSamu)\
**Post date:** [April 18, 2022, 1:40pm UTC](https://discourse.julialang.org/t/python-implemention-in-julia/79522/23 "2022-04-18T13:40:32Z")

</div>

> [@johnmyleswhite](#):
>
> So not transpilation, but literally writing a Python interpreter in Julia.

_Deep learning is the future_ of programming.

idea:  
IF we can add “Julia” processor to the [https://github.com/facebookresearch/CodeGen](https://github.com/facebookresearch/CodeGen) project  
THEN we can convert `C/C++/Java/Python` to Julia. ( or back )

The next step: convert the CPython to Julia ( with the `C->Julia` translator )

related:

> **[Deep learning to translate between programming languages](https://ai.meta.com/blog/deep-learning-to-translate-between-programming-languages/)**
>
> TransCoder is the first self-supervised neural transcompiler system for migrating code between programming languages. It can translate code from Python to C++, for example, and it outperforms rule-based translation programs.

---

<div class="post-metadata">

**Author:** ![Henrique\_Becker](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/henrique_becker/32/15443_2.png) [@Henrique\_Becker](https://discourse.julialang.org/u/Henrique_Becker)\
**Post date:** [April 18, 2022, 2:23pm UTC](https://discourse.julialang.org/t/python-implemention-in-julia/79522/24 "2022-04-18T14:23:38Z")

</div>

> [@ImreSamu](#):
>
> _Deep learning is the future_ of programming.

I reeeeealy hope it is not. And with the many time AI has embarked a hype train to hit a wall, it will probably not be.

---

<div class="post-metadata">

**Author:** ![goerch](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/goerch/32/29122_2.png) [@goerch](https://discourse.julialang.org/u/goerch)\
**Post date:** [April 18, 2022, 2:44pm UTC](https://discourse.julialang.org/t/python-implemention-in-julia/79522/25 "2022-04-18T14:44:31Z")

</div>

> [@Henrique\_Becker](#):
>
> I reeeeealy hope it is not. And with the many time AI has embarked a hype train to hit a wall, it will probably not be.

It will bring a whole new class of nearly incomprehensible bugs 🙂

---

<div class="post-metadata">

**Author:** ![Henrique\_Becker](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/henrique_becker/32/15443_2.png) [@Henrique\_Becker](https://discourse.julialang.org/u/Henrique_Becker)\
**Post date:** [April 18, 2022, 5:04pm UTC](https://discourse.julialang.org/t/python-implemention-in-julia/79522/26 "2022-04-18T17:04:39Z")

</div>

It already brought. In fact, currently one hot topic of research with big tech putting some money in it is “how to make deep learning less of a blackbox”. The classical example is the classifier learning to classify between wolves and dogs by learning to detect snow (i.e., an white background) instead of anything directly related to wolves and dogs.

---

<div class="post-metadata">

**Author:** ![Palli](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/palli/32/3380_2.png) [@Palli](https://discourse.julialang.org/u/Palli)\
**Post date:** [April 21, 2022, 6:53pm UTC](https://discourse.julialang.org/t/python-implemention-in-julia/79522/27 "2022-04-21T18:53:54Z")

</div>

FYI: The closest I know of is:

> **[GitHub - TotalVerb/PythonSyntax.jl: A pythonic syntax for Julia (for fun, not for...](https://github.com/TotalVerb/PythonSyntax.jl)**
>
> A pythonic syntax for Julia (for fun, not for serious use)

> A pythonic syntax for Julia (for fun, not for serious use)

[It’s not maintained for Julia 1.0+ (unlike LispSyntax.jl similar in spirit), but should be easy to resurrect…]

There’s not point in reimplementing Python i.e. syntax and semantics, in Julia. But it could be done, similar to APL implemented in APL.jl. I just don’t see any upside (just plenty of downsides) to reimplement Python once again, not for us, not for Python or Rust users.

What I find valuable is being able to call to and from Python (without any overhead, possible with e.g. PythonCall.jl), and same for R and more.

Why RustPython was done, is maybe for them to say, a hobby project (actually many, that got merged or abandoned)? Still, they might need a good other language with a REPL, or just wanted faster Python. We have the speed (like Rust and C).

In time it may be helpful to being able to call RustPython or Pyston or whatever alternative good Python implementation, but I only call Python for features/library access, more so than for speed (and often those “Python” libraries are fast enough; as also implemented in C).

What might be helpful is to be able to reuse CPython extensions, directly, or more likely the extensions to R (since it doesn’t run in the same process, when used with Julia?). And vise versa, also useful, using Julia this way from other languages, there from Python:

> [@Successful Static Compilation of Julia Code for use in Production](https://discourse.julialang.org/t/successful-static-compilation-of-julia-code-for-use-in-production/79318):
>
> The [StaticCompiler](https://github.com/tshort/StaticCompiler.jl) package was recently registered. This post records a successful experiment to statically compile a piece of Julia code into a small .so library on Linux, which is then loaded from Python and used in training of a deep learning model. TLDR Static compilation to a stand-alone library does work on Linux but has rather significant restrictions on the functionality available. It is mostly useful for core computational routines. Roughly speaking, if it could be implemented in plain…

[Previous page](https://discourse.julialang.org/t/python-implemention-in-julia/79522.md?page=1)
