or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

docs

console-scripts.mdcore-runtime.mddevelopment-tools.mdindex.mdipython-integration.mdlow-level-api.md
tile.json

tessl/pypi-julia

Julia/Python bridge with IPython support enabling seamless interoperability between Python and Julia programming languages.

Workspace
tessl
Visibility
Public
Created
Last updated
Describes
pypipkg:pypi/julia@0.6.x

To install, run

npx @tessl/cli install tessl/pypi-julia@0.6.0

index.mddocs/

PyJulia

A comprehensive Python library that enables seamless interoperability between Python and Julia programming languages. PyJulia allows Python developers to call Julia functions directly from Python code, leverage Julia's high-performance numerical computing capabilities within Python workflows, and provides automatic type conversion between Python and Julia data structures.

Package Information

  • Package Name: julia
  • Language: Python
  • Installation: pip install julia
  • Version: 0.6.2

Core Imports

import julia

For the main Julia interface:

from julia import Julia

For accessing Julia modules directly:

from julia import Base, Main

For IPython/Jupyter magic commands:

%load_ext julia.magic

Basic Usage

import julia

# Install required Julia packages (run once)
julia.install()

# Create Julia interface
jl = julia.Julia()

# Access Julia's Base module
from julia import Base

# Call Julia functions
result = Base.sind(90)  # Sin in degrees
print(result)  # 1.0

# Execute Julia code directly
jl.eval('println("Hello from Julia!")')

# Access Julia variables
jl.eval('x = [1, 2, 3, 4, 5]')
x = jl.eval('x')
print(x)  # [1, 2, 3, 4, 5]

# Use Julia's powerful array operations
import numpy as np
arr = np.array([1.0, 2.0, 3.0])
jl_result = jl.eval('sum(x -> x^2, [1, 2, 3])')
print(jl_result)  # 14.0

Architecture

PyJulia implements a multi-layered architecture for Python-Julia interoperability:

  • High-level Interface: Julia class provides easy-to-use Python API with automatic type conversion
  • Module System: Direct importing of Julia modules (from julia import Base, Main)
  • Low-level API: LibJulia class provides direct access to Julia's C API for advanced users
  • IPython Integration: Magic commands and completion for interactive Jupyter workflows
  • Console Scripts: julia-py and python-jl executables for command-line integration

This design enables both casual scientific computing users and performance-critical applications to leverage Julia's capabilities from Python environments.

Capabilities

Core Julia Runtime

Primary interface for executing Julia code from Python, including runtime initialization, module importing, function calling, and automatic type conversion between Python and Julia data structures.

class Julia:
    def __init__(self, runtime=None, jl_init_path=None, **kwargs): ...
    def eval(self, code: str): ...
    def using(self, module_name: str): ...

def install(julia="julia", color="auto", python=None, quiet=False): ...

# Direct module access
from julia import Base, Main

Core Runtime

IPython and Jupyter Integration

Magic commands, code completion, and interactive development features for Jupyter notebooks and IPython environments, including Revise.jl integration for automatic code reloading.

class JuliaMagics:
    def julia(self, line, cell=None): ...  # Line and cell magic
    
# Magic command usage in Jupyter
%julia code
%%julia
multi-line
code

IPython Integration

Low-level LibJulia API

Direct access to Julia's C API for advanced users who need fine-grained control over the Julia runtime, memory management, and performance-critical operations.

class LibJulia:
    def __init__(self, **kwargs): ...
    def eval_string(self, code: str): ...
    def call(self, func, *args): ...

def get_libjulia(): ...
def set_libjulia(libjulia): ...

Low-level API

Development Tools and Utilities

Utilities for PyCall.jl installation, system image building, testing infrastructure, and development workflow support including PyCall rebuild and Julia executable management.

def install(julia="julia", color="auto", python=None, quiet=False): ...
def build_pycall(julia="julia", python=sys.executable, **kwargs): ...
def build_sysimage(output, julia="julia", script=None, debug=False): ...

Development Tools

Console Scripts and Entry Points

Command-line utilities for running Julia through PyJulia (julia-py) and Python within Julia processes (python-jl), providing seamless integration for shell-based workflows.

# Console scripts (available after installation)
# julia-py [julia-options] [script] [script-args]
# python-jl [python-options] [script] [script-args]

Console Scripts

Types

class JuliaError(Exception):
    """Wrapper for Julia exceptions raised during execution."""

class JuliaNotFound(Exception):
    """Raised when Julia executable cannot be found."""

class UnsupportedPythonError(Exception):
    """Raised for unsupported Python configurations."""

class JuliaModule:
    """Represents a Julia module accessible from Python."""

class JuliaMainModule(JuliaModule):
    """Special Julia Main module with assignment support."""