Julia extension for Python - write Julia code in Python functions like Numba
Project description
jlext
像 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
Release history Release notifications | RSS feed
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.0.tar.gz
(6.0 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
jlext-0.1.0-py3-none-any.whl
(6.6 kB
view details)
File details
Details for the file jlext-0.1.0.tar.gz.
File metadata
- Download URL: jlext-0.1.0.tar.gz
- Upload date:
- Size: 6.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a92994b258a87ec7b7180c148ba0f8343d0c542a90767c699f2f494712796a0f
|
|
| MD5 |
2f4d15a28c84f55c18c2d8f5a81a6be5
|
|
| BLAKE2b-256 |
041bce5bf169d77eb9375b0b5e0b51b04068ac85471ec8e0b81425418efec850
|
File details
Details for the file jlext-0.1.0-py3-none-any.whl.
File metadata
- Download URL: jlext-0.1.0-py3-none-any.whl
- Upload date:
- Size: 6.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2afde8b5d01369fee4628e5a039679300c34524a6b0e0f1ac8c84dd8c593bf59
|
|
| MD5 |
e7db08bebe0f34a7af731993a50d1b17
|
|
| BLAKE2b-256 |
da4ed6cb082b72478a976782fa7e4b719cf88edfad39d575611efaa9a01550d9
|