Add scalar Complex boxing/unboxing across the jl2py ABI#4
Merged
Conversation
760bb77 to
93ea7ed
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Scalar
Complexwas the one input/output gap in the otherwise-complete bridge(arrays of complex already worked). For a quantum-control codebase (Piccolo's
PAULIS/GATES/Hamiltonians are complex) this is first-class, so:
Input —
box_python_valueboxes a Pythoncomplex→ JuliaComplex{Float64}via new C
jl2py_box_complex128(Base.complex(re, im)).Output —
compute_typetagnow emitsTAG_COMPLEX128/TAG_COMPLEX64for scalarComplex{Float64}/{Float32}(cached at init), and newJuliaComplex128/JuliaComplex64wrappers expose
__complex__/.real/.imagvia new Cjl2py_unbox_complex128.Before: a Python
complexarg raisedTypeError; a scalarComplexresult fellthrough to bare
JuliaAny(no.real/__complex__;.re/.imworked but un-Pythonic).Verified locally on Julia 1.12.6 (libjl2py rebuilt clean):
ComplexF32promoted; complex as a kwarg value;scalar complex from a runtime-loaded module tags + wraps correctly with no world-age wall.
Adds
tests/test_complex.py(numpy-free; mirrors the existing regression-test style).🤖 Generated with Claude Code