Skip to main content

Julia extension for Python - write Julia code in Python functions like Numba

Project description

jlext

English | 日本語 | 한국어

像 Numba 一样,在 Python 函数中直接编写和运行 Julia 代码。

安装

pip install jlext

也可以从 GitHub 安装最新版:

pip install git+https://github.com/yikuide-lab/jlext.git

需要预先安装 Julia

快速开始

@julia 装饰器

from jlext import julia

@julia
def fibonacci(n):
    """
    if n <= 1
        return n
    end
    a, b = 0, 1
    for _ in 2:n
        a, b = b, a + b
    end
    return b
    """

fibonacci(10)  # → 55,在 Julia 中执行

批量调用(24x 加速)

results = fibonacci.map([(10,), (20,), (30,)])
# → [55, 6765, 832040]

快速求值

from jlext import julia_eval, julia_exec

julia_eval("sum(1:100)")     # → 5050
julia_exec("using Statistics")

使用 Julia 包

from jlext import JuliaModule

la = JuliaModule("LinearAlgebra")
la.norm([1.0, 2.0, 3.0])  # → 3.7416...

API

API 用途
@julia 装饰器,函数体用 docstring 写 Julia 代码
func.map(args_list) 批量调用,减少跨语言开销
julia_eval(expr) 求值 Julia 表达式(结果自动缓存)
julia_exec(code) 执行 Julia 语句
JuliaModule(name) 导入 Julia 模块并访问其成员

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

jlext-0.1.1.tar.gz (6.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

jlext-0.1.1-py3-none-any.whl (6.7 kB view details)

Uploaded Python 3

File details

Details for the file jlext-0.1.1.tar.gz.

File metadata

  • Download URL: jlext-0.1.1.tar.gz
  • Upload date:
  • Size: 6.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.3

File hashes

Hashes for jlext-0.1.1.tar.gz
Algorithm Hash digest
SHA256 0d76412c31647cb8079e52839e833628427e61c9cf0c5e28be5bb5028f5bb501
MD5 57d0df36fc365c056075356452a4478b
BLAKE2b-256 b83679952f3b5ff160a7d7d0237aa7460b36f35adba1713f081da4ec886b647b

See more details on using hashes here.

File details

Details for the file jlext-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: jlext-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 6.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.3

File hashes

Hashes for jlext-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 7ff5092ff93911262d8f62b72a51dcf52c4ebefa2e2b0caae7eb433c0de3bf52
MD5 03214112004643771ef7f64d1a543132
BLAKE2b-256 bb3e9c3aff7d97aa14904b2de8b229e54cb70d97380d486df3a51b1b18f40cd1

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page