JuliaPy / JuliaPy/pyjulia

Redesign

Open
#134 12 comments 8 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
893
Forks
101
PR merge metrics
No merged PRs in 30d

Description

I've been kicking around some ideas for a different "calling Julia from Python" interface. While it may not replace pyjulia, this seems like a good venue to start the discussion.

The core of the idea is that a user would declare their the Julia functions they want exported to Python in a Julia file. e.g. they could have a file `foo.jl` containing
```julia
using PyCall

@pyexport sin(x::Float64)
```

Then on the python side pyjulia would provide hook into the [Python importlib system](https://docs.python.org/3/library/importlib.html), so that a user could just write:
```python
import julia
import foo # would look up foo.jl if no foo.py exists
foo.sin(1.0)
```
Essentially, pyjulia would only be responsible for the importlib hooks and initialising the Julia kernel.

This is a little less "dynamic" than the current pyjulia approach, but I think there are some advantages
- it can be faster since the callbacks can make use of type inference on the arguments
- it should hopefully reduce segfaults by clearly defining an interface and restricting the types which are transferred back and forth
- it should avoid the need for calling the Julia eval from Python, since you can just add that code to the Julia file.
- it might make it possible to do static compilation: e.g. you would be able to compile the julia script into one dylib which Python just sees as an ordinary extension module (so you wouldn't need the `import julia` at the start).
- Julia packages could define their Python interface in their own repo

Obviously, there is still a lot to be determined, e.g. how the `@pyexport` would handle conversions, but I wanted to elicit some feedback on the idea.

cc: @ViralBShah @StefanKarpinski @rejuvyesh @stevengj

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.