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
michalmuskala
Hello everybody. I have just released Jason - a new JSON library. You might be wondering, why do we need a new library? The primary foc...
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
tfwright
After working on it for a couple of months and using it in production for most of that time, today I’ve released LiveAdmin, a LiveView ba...
New
woylie
Flop is an Elixir library that applies filtering, ordering and pagination parameters to your Ecto queries. offset-based pagination with...
New
zoltanszogyenyi
Hey everyone :waving_hand: Excited to join this forum - I am one of the founders and current project maintainers of a popular and open-s...
New
bluzky
You may know https://ui.shadcn.com/, a UI component library for React. I really love it’s design style and components. I’ve built some co...
384 14553 119
New

Other popular topics Top

joaquinalcerro
Hi there, I am working with Ecto-Postgresql and I need to call all of the records from a specific table but the table has 40,000 records...
New
Qqwy
Original source of discussion: This topic on the Pragmatic Programmers’ Functional Web Development with Elixir, OTP, and Phoenix forum. ...
New
vonH
In asking this question I am more interested about the expressiveness of the language itself and less concerned about the availability of...
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
sen
Hi All, I set a environment variables in dev.exs , like below code. when i start server, how can i set the ${enable} value? thanks. d...
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

We're in Beta

About us Mission Statement