Skip to content

Commit 77341af

Browse files
author
Christopher Doris
committed
Merge remote-tracking branch 'origin/main' into refactor
2 parents 69f9c93 + d4baa18 commit 77341af

File tree

5 files changed

+19
-4
lines changed

5 files changed

+19
-4
lines changed

docs/src/juliacall.md

+1
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ be configured in two ways:
124124
| `-X juliacall-threads=<N\|auto>` | `PYTHON_JULIACALL_THREADS=<N\|auto>` | Launch N threads. |
125125
| `-X juliacall-warn-overwrite=<yes\|no>` | `PYTHON_JULIACALL_WARN_OVERWRITE=<yes\|no>` | Enable or disable method overwrite warnings. |
126126
| `-X juliacall-autoload-ipython-extension=<yes\|no>` | `PYTHON_JULIACALL_AUTOLOAD_IPYTHON_EXTENSION=<yes\|no>` | Enable or disable IPython extension autoloading. |
127+
| `-X juliacall-heap-size-hint=<N>` | `PYTHON_JULIACALL_HEAP_SIZE_HINT=<N>` | Hint for initial heap size in bytes. |
127128

128129
## [Multi-threading](@id py-multi-threading)
129130

docs/src/releasenotes.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Release Notes
22

3+
## Unreleased
4+
* Added `PYTHON_JULIACALL_HEAP_SIZE_HINT` option to configure initial Julia heap size.
5+
* `Base.elsize` now defined for `PyArray`.
6+
37
## 0.9.24 (2025-01-22)
48
* Bug fixes.
59

pysrc/juliacall/__init__.py

+5-4
Original file line numberDiff line numberDiff line change
@@ -125,9 +125,9 @@ def int_option(name, *, accept_auto=False, **kw):
125125
f"{s}: expecting an int" + (" or auto" if accept_auto else "")
126126
)
127127

128-
def args_from_config():
129-
argv = [CONFIG["exepath"]]
130-
for opt, val in CONFIG.items():
128+
def args_from_config(config):
129+
argv = [config["exepath"]]
130+
for opt, val in config.items():
131131
if opt.startswith("opt_"):
132132
if val is None:
133133
if opt == "opt_handle_signals":
@@ -164,6 +164,7 @@ def args_from_config():
164164
CONFIG["opt_warn_overwrite"] = choice("warn_overwrite", ["yes", "no"])[0]
165165
CONFIG["opt_handle_signals"] = choice("handle_signals", ["yes", "no"])[0]
166166
CONFIG["opt_startup_file"] = choice("startup_file", ["yes", "no"])[0]
167+
CONFIG["opt_heap_size_hint"] = option("heap_size_hint")[0]
167168

168169
# Stop if we already initialised
169170
if CONFIG["inited"]:
@@ -208,7 +209,7 @@ def args_from_config():
208209
CONFIG["lib"] = lib = c.PyDLL(libpath, mode=c.RTLD_GLOBAL)
209210

210211
# parse options
211-
argc, argv = args_from_config()
212+
argc, argv = args_from_config(CONFIG)
212213
jl_parse_opts = lib.jl_parse_opts
213214
jl_parse_opts.argtypes = [c.c_void_p, c.c_void_p]
214215
jl_parse_opts.restype = None

src/Wrap/PyArray.jl

+2
Original file line numberDiff line numberDiff line change
@@ -570,6 +570,8 @@ Base.IndexStyle(::Type{PyArray{T,N,M,L,R}}) where {T,N,M,L,R} =
570570

571571
Base.unsafe_convert(::Type{Ptr{T}}, x::PyArray{T,N,M,L,T}) where {T,N,M,L} = x.ptr
572572

573+
Base.elsize(::Type{PyArray{T,N,M,L,T}}) where {T,N,M,L} = sizeof(T)
574+
573575
Base.strides(x::PyArray{T,N,M,L,R}) where {T,N,M,L,R} =
574576
if all(mod.(x.strides, sizeof(R)) .== 0)
575577
div.(x.strides, sizeof(R))

test/Wrap.jl

+7
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,13 @@
2626
@test strides(y) === (1,)
2727
@test strides(z) === (1,)
2828
end
29+
@testset "elsize" begin
30+
@test Base.elsize(y) === sizeof(Cint)
31+
@test Base.elsize(z) === sizeof(Cint)
32+
@test Base.elsize(PyArray{Cint,1,true,true,Cint}) === sizeof(Cint)
33+
@test Base.elsize(PyArray{Cint,1,false,false,Cint}) === sizeof(Cint)
34+
@test_throws Exception elsize(PyArray{Cint,1,true,false,Cchar})
35+
end
2936
@testset "getindex" begin
3037
@test_throws BoundsError y[0]
3138
@test y[1] == 1

0 commit comments

Comments
 (0)