Piton

hex.pmhexdocs.pmBuild Status

Piton is a library which will help you to run your Python code.

You can implement your own Piton.Port and run your python code but I highly recommend to use Piton.Pool, a pool which will allow to run Python code in parallel, a way of avoiding the GIL, and it will protect you from python exceptions.

Installation

Add piton to your list of dependencies in mix.exs:

  def deps do
    [{:piton, "~> 0.3.0"}]
  end

How to use it

Define your own port

Run a Pool

Pay attention to the number of Pythons you want to run in parallel. It does not exist an optimal number, maybe it is the number of cores, maybe half or maybe double. Test it with your application.

  {:ok, pool} = Piton.Pool.start_link([module: MyPoolPort, pool_number: pool_number], [])

Call a Port (No pool)

  iex> MyCustomPort.execute(pid_of_the_port, python_module, python_function, list_of_arguments_of_python_function)

Call a Pool

  iex> Piton.Pool.execute(pid_of_the_pool, elixir_function, list_of_arguments_of_elixir_function)

Tasks

Some Mix.Tasks have been included in order to facilitate the integration of a python project

Test

Run the tests.

  mix test 

Name

Pitón is only Python in Spanish :stuck_out_tongue_winking_eye: :snake: