benoitc

benoitc

Erlang_python - Run Python across your Elixir cluster

Because it runs on the BEAM, you inherit Erlang/Elixir distribution for free.
Run Python on any node:

# Execute on remote node
:rpc.call(:"worker@host", :py, :call, [:numpy, :dot, [matrix_a, matrix_b]])

# Local call
{:ok, result} = :py.call(:sklearn, :fit, [model, data])

# Async task
{:ok, ref} = :py_event_loop.create_task(:heavy_compute, :run, [data])
# ... do other work ...
{:ok, result} = :py_event_loop.await(ref)

Key features:

  • Distributed by default via rpc:call
  • Async Task API (uvloop-inspired)
  • Channel API for bidirectional streaming
  • OWN_GIL subinterpreters (Python 3.12+)
  • Virtual environment management
  • ASGI/WSGI support

erlang_python 2.1 is out with async tasks and channel-based streaming.

Hex: erlang_python | Hex
GitHub:

https://github.com/benoitc/erlang-python

Apache 2.0 licensed.

Most Liked

benoitc

benoitc

erlang_python embeds Python with true parallelism via sub-interpreters (each with its own GIL) or free-threading (no GIL). You get bidirectional communication: channels, async/await, and Python calling back into Erlang. Pythonx is designed for Livebook/Elixir with a single Python interpreter and shared GIL, which is enough for notebooks but limited for concurrent production workloads.

Afaik erlang_python is built to run Python applications inside the Erlang VM and inherit its efficiency.

Asd

Asd

Nice library!

I tried to read the code, but the project is huge and NIF part is around 15k lines of C code (thats around 5% of whole OTP C code size).

I think that it was generated, given that project is +90k lines in a month from you. Given that, it is strange to see that it is 2.1.0 version already. For me it feels more like its pre 1.0.0 version, given that it was rapidly developed and I assume was not used by anybody except you yet

Do you have any benchmarks? I am curious about how it compares to Snex, which uses erlang ports to spawn multiple interpreters and has very very tiny NIF surface. I think that erlang-python should be faster

Do you use it in production? What’s your use-case?

LostKobrakai

LostKobrakai

I’m curious about how this is different to pythonx?

Last Post!

gtcode

gtcode

This is really cool — there’s a lot of Python+Elixir crossover happening right now.

I built a Python FFI for Elixir: https://github.com/nshkrdotcom/snakebridge

Then put together a sample project to test whether pooling Python workers from the BEAM side buys anything over straight Python. Turns out non-GIL Python is pretty capable on its own: https://github.com/nshkrdotcom/slither

That said, the whole stack is still a prototype — glued together with gRPC and architecturally rough. Feel free to steal anything useful. Really glad to see your project.

Where Next?

Popular in Announcing Top

handnot2
Samly can be used to enable SAML 2.0 Single Sign On in a Plug/Phoenix application. This library uses Erlang esaml to provide plug enabl...
New
mspanc
I am pleased to announce an initial release of the Membrane Framework - an Elixir-based framework with special focus on processing multim...
New
kip
ex_cldr provides localisation and internationalisation support based upon the data from the Unicode CLDR project. Unicode released CLDR ...
407 13256 120
New
sorentwo
Hello! tl;dr Announcing Oban, an Ecto based job processing library with a focus on reliability and historical observability. After spen...
985 44532 311
New
oltarasenko
Dear Elixir community, After a year of development, bug fixes, and improvements, we are proudly ready to share the release of Crawly 0.1...
New
dominicletz
Hi, I thought I had posted my library before but seems I hadn’t. The project is still in early stages but it’s growing and so I think it...
New
kip
Image is an image processing library for Elixir. It is based upon the fabulous vix library that provides a libvips wrapper for Elixir. I...
622 19460 194
New

Other popular topics Top

Darmani72
If I have a post route which an argument: post /my_post_route/:my_param1, MyController.my_post_handler How would get the post params ...
New
gshaw
What is the idiomatic way of matching for not nil in Elixir? E.g., First way: defp halt_if_not_signed_in(conn, signed_in_account) when...
New
shijith.k
I am trying to start a new phoenix project with elixir 1.9, but mix phx.new does not work. It says that ** (Mix) The task "phx.new" could...
New
msaraiva
Surface is an experimental library built on top of Phoenix LiveView and its new LiveComponent API that aims to provide a more declarative...
564 44139 214
New
SoCreat
i’m a new one to elixir which editor can i use vs code? or atom? Thanks! :smiley:
New
jason.o
In the code below, if the create action is not set to accept “extra_key” as an input, it errors out with a message shown above. Is there ...
New

We're in Beta

About us Mission Statement